java.lang.Object
net.thucydides.model.domain.Story

public class Story extends Object
Represents a given user story or feature. Used to record test results and so on.
  • Constructor Details

  • Method Details

    • pathOf

      public static String pathOf(Class<?> userStoryClass)
    • getId

      public String getId()
    • from

      public static Story from(Class<?> userStoryClass)
      Obtain a story instance from a given story class. Story instances are used for recording and reporting test results.
    • withId

      public static Story withId(String storyId, String storyName)
      Create a story using a full class name as an id. Note that the class may no longer exist, so the story needs to be able to exist beyond the life of the original story class. This is used to deserialize stories from XML files.
    • withNarrative

      public Story withNarrative(String narrative)
    • withType

      public Story withType(String type)
    • withIdAndPath

      public static Story withIdAndPath(String storyId, String storyName, String storyPath)
    • withDisplayName

      public Story withDisplayName(String name)
    • withStoryName

      public Story withStoryName(String name)
    • called

      public static Story called(String storyName)
    • withId

      public static Story withId(String storyId, String storyName, String featureClassName, String featureName)
    • withIdAndPathAndFeature

      public static Story withIdAndPathAndFeature(String storyId, String storyName, String storyPath, String featureClassName, String featureName)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getFeatureClass

      public static Class<?> getFeatureClass(Class<?> userStoryClass)
      What feature does this story belong to?
    • testedInTestCase

      public static Class<?> testedInTestCase(Class<?> testClass)
      Returns the class representing the story that is tested by a given test class This is indicated by the Story annotation's storyClass attribute.
    • storyNameDefinedIn

      public static String storyNameDefinedIn(Class<?> testClass)
      Returns the string-based story name defined on a class via @Story("name"), or null if not present.
    • storyNameDefinedIn

      public static String storyNameDefinedIn(Method method)
      Returns the string-based story name defined on a method via @Story("name"), or null if not present.
    • fromAnnotationsOn

      public static Story fromAnnotationsOn(Class<?> testClass)
      Builds a Story with a proper requirements hierarchy from string-based @Epic, @Feature, and @Story annotations on the given class. Walks the superclass chain so that annotations on parent classes are inherited. Returns null if no string-based annotations are present.

      The hierarchy is: Epic > Feature > Story. The path is built from whichever levels are present.

    • fromAnnotationsOn

      public static Story fromAnnotationsOn(Class<?> testClass, String defaultStoryName)
      Builds a Story with a proper requirements hierarchy from string-based @Epic, @Feature, and @Story annotations on the given class. When @Story is absent but @Feature or @Epic is present, uses the defaultStoryName (typically from @DisplayName) as the story name, nesting it under the feature/epic in the hierarchy.
      Parameters:
      testClass - the test class to read annotations from
      defaultStoryName - fallback story name when no @Story annotation is present (e.g. from @DisplayName)
      Returns:
      a Story with the requirements hierarchy, or null if no annotations are present
    • getName

      public String getName()
      Each story has a descriptive name. This name is usually a human-readable version of the class name, or the story name for an easyb story.
    • getDisplayName

      public String getDisplayName()
    • getStoryClassName

      public String getStoryClassName()
    • getReportName

      public String getReportName(ReportType type)
      Find the name of the report for this story for the specified report type (XML, HTML,...).
    • getReportName

      public String getReportName()
    • getFeature

      public ApplicationFeature getFeature()
    • getPath

      public String getPath()
    • getRelativePath

      public String getRelativePath(List<String> rootElements)
    • getParentPathElements

      public PathElements getParentPathElements()
    • getPathElements

      public PathElements getPathElements()
    • getStoryName

      public String getStoryName()
    • getNarrative

      public String getNarrative()
    • getNarrativeSummary

      public String getNarrativeSummary()
    • getType

      public String getType()
    • withPath

      public Story withPath(String path)
    • asFeature

      public Story asFeature()
    • asTag

      public TestTag asTag()
    • asQualifiedTag

      public TestTag asQualifiedTag()
    • asSingleParentTag

      public TestTag asSingleParentTag()