class Scenario(Scenario): @given(u"A requirements catalogue containing user requirements") def given(self): from corejet.core.model import RequirementsCatalogue, Epic, Story self.catalogue = RequirementsCatalogue(project="Test project", extractTime=datetime.datetime(2011, 1, 2, 12, 1, 0)) epic1 = Epic("E1", "First epic") self.catalogue.epics.append(epic1) story1 = Story("S1", "First story", points=3, status="open", priority="high", epic=epic1) epic1.stories.append(story1) text = u"""\ # language: fi Tapausaihio: Montako yötä on jouluun Oletetaan, että tänään on <päivä>. joulukuuta. Kun avaan vielä <avaukset> luukkua joulukalenterista, niin jouluun on enää <jäljellä> yötä. Tapaukset: | päivä | avaukset | jäljellä | | 1 | 2 | 21 | | 21 | 3 | 0 | """ appendScenarios(story1, text) @when(u"The serialize() method is called") def when(self): self.tree = self.catalogue.serialize() @then(u"An XML tree is output containing epic, story and scenario") def then(self): self.assertEqual( unicode(lxml.etree.tostring(self.tree, pretty_print=True, encoding="utf-8"), "utf-8").strip(), u"""\ <requirementscatalogue project="Test project" extractTime="2011-01-02T12:01:00"> <epic id="E1" title="First epic"> <story id="S1" title="First story" points="3" requirementStatus="open" priority="high"> <scenario name="Montako yötä on jouluun #01"> <given>tänään on 1. joulukuuta</given> <when>avaan vielä 2 luukkua joulukalenterista</when> <then>jouluun on enää 21 yötä</then> </scenario> <scenario name="Montako yötä on jouluun #02"> <given>tänään on 21. joulukuuta</given> <when>avaan vielä 3 luukkua joulukalenterista</when> <then>jouluun on enää 0 yötä</then> </scenario> </story> </epic> </requirementscatalogue>""".strip())
class Scenario(Scenario): @given(u"A requirements catalogue containing user requirements") def given(self): from corejet.core.model import RequirementsCatalogue, Epic, Story self.catalogue = RequirementsCatalogue(project="Test project", extractTime=datetime.datetime(2011, 1, 2, 12, 1, 0)) epic1 = Epic("E1", "First epic") self.catalogue.epics.append(epic1) story1 = Story("S1", "First story", points=3, status="open", priority="high", epic=epic1) epic1.stories.append(story1) text = u"""\ # language: fi Tapaus: Ensimmäinen tapaus Oletetaan, että ajan polkupyörällä, mutta minulla ei ole pyöräilykypärää. Kun törmään liikenteessä autoon, niin minulle käy tosi huonosti, mutta auton kuljettaja voi selvitä vammoitta. """ appendScenarios(story1, text) @when(u"The serialize() method is called") def when(self): self.tree = self.catalogue.serialize() @then(u"An XML tree is output containing epic, story and scenario") def then(self): self.assertEqual( unicode(lxml.etree.tostring(self.tree, pretty_print=True, encoding="utf-8"), "utf-8").strip(), u"""\ <requirementscatalogue project="Test project" extractTime="2011-01-02T12:01:00"> <epic id="E1" title="First epic"> <story id="S1" title="First story" points="3" requirementStatus="open" priority="high"> <scenario name="Ensimmäinen tapaus"> <given>ajan polkupyörällä</given> <given>minulla ei ole pyöräilykypärää</given> <when>törmään liikenteessä autoon</when> <then>minulle käy tosi huonosti</then> <then>auton kuljettaja voi selvitä vammoitta</then> </scenario> </story> </epic> </requirementscatalogue>""".strip())
class MinimalOutput(Scenario): @given("An empty requirements catalogue") def create(self): from corejet.core.model import RequirementsCatalogue self.catalogue = RequirementsCatalogue() @when("The serialize() method is called") def serialize(self): self.tree = self.catalogue.serialize() @then("A minimal XML tree is output") def checkOutput(self): output = lxml.etree.tostring(self.tree) self.assertEqual(output, '<requirementscatalogue/>')
class Scenario(Scenario): @given(u"A requirements catalogue containing user requirements") def given(self): from corejet.core.model import RequirementsCatalogue, Epic, Story self.catalogue = RequirementsCatalogue(project="Test project", extractTime=datetime.datetime(2011, 1, 2, 12, 1, 0)) epic1 = Epic("E1", "First epic") self.catalogue.epics.append(epic1) story1 = Story("S1", "First story", points=3, status="open", priority="high", epic=epic1) epic1.stories.append(story1) text = u"""\ # language: fi Tapaus: Toinen tapaus Oletetaan, että olen 1. ja 2. korttelin välissä. Kun katson suoraan oikealle niin näen uuden kirjakaupan ja kauniin näyteikkunan. """ appendScenarios(story1, text) @when(u"The serialize() method is called") def when(self): self.tree = self.catalogue.serialize() @then(u"An XML tree is output containing epic, story and scenario") def then(self): self.assertEqual( unicode(lxml.etree.tostring(self.tree, pretty_print=True, encoding="utf-8"), "utf-8").strip(), u"""\ <requirementscatalogue project="Test project" extractTime="2011-01-02T12:01:00"> <epic id="E1" title="First epic"> <story id="S1" title="First story" points="3" requirementStatus="open" priority="high"> <scenario name="Toinen tapaus"> <given>olen 1. ja 2. korttelin välissä</given> <when>katson suoraan oikealle</when> <then>näen uuden kirjakaupan</then> <then>kauniin näyteikkunan</then> </scenario> </story> </epic> </requirementscatalogue>""".strip())
class MinimalOutput(Scenario): @given("An empty requirements catalogue") def create(self): from corejet.core.model import RequirementsCatalogue self.catalogue = RequirementsCatalogue() @when("The serialize() method is called") def serialize(self): self.tree = self.catalogue.serialize() @then("A minimal XML tree is output") def checkOutput(self): output = lxml.etree.tostring(self.tree) self.assertEqual(output, '<requirementscatalogue/>')
class Scenario(Scenario): @given(u"A requirements catalogue containing user requirements") def given(self): from corejet.core.model import RequirementsCatalogue, Epic, Story self.catalogue = RequirementsCatalogue(project="Test project", extractTime=datetime.datetime(2011, 1, 2, 12, 1, 0)) epic1 = Epic("E1", "First epic") self.catalogue.epics.append(epic1) story1 = Story("S1", "First story", points=3, status="open", priority="high", epic=epic1) epic1.stories.append(story1) text = u"""\ # language: fi Tapaus: RTFM suomeksi Oletetaan, että olen pulassa. Kun klikkaan "Ohjeet"-linkkiä, niin löydän apua. """ appendScenarios(story1, text) @when(u"The serialize() method is called") def when(self): self.tree = self.catalogue.serialize() @then(u"An XML tree is output containing epic, story and scenario") def then(self): self.assertEqual( unicode(lxml.etree.tostring(self.tree, pretty_print=True, encoding="utf-8"), "utf-8").strip(), u"""\ <requirementscatalogue project="Test project" extractTime="2011-01-02T12:01:00"> <epic id="E1" title="First epic"> <story id="S1" title="First story" points="3" requirementStatus="open" priority="high"> <scenario name="RTFM suomeksi"> <given>olen pulassa</given> <when>klikkaan 'Ohjeet'-linkkiä</when> <then>löydän apua</then> </scenario> </story> </epic> </requirementscatalogue>""".strip())
class Scenario(Scenario): @given(u"A requirements catalogue containing user requirements") def given(self): from corejet.core.model import RequirementsCatalogue, Epic, Story self.catalogue = RequirementsCatalogue( project="Test project", extractTime=datetime.datetime(2011, 1, 2, 12, 1, 0)) epic1 = Epic("E1", "First epic") self.catalogue.epics.append(epic1) epic2 = Epic("E2", "Second epic") self.catalogue.epics.append(epic2) story1 = Story("S1", "First story", points=3, status="open", priority="high", epic=epic1) epic1.stories.append(story1) story2 = Story("S2", "Second story", points=3, status="closed", resolution="fixed", priority="high", epic=epic1) epic1.stories.append(story2) text = """\ Scenario Outline: Count some apples Given I have <Start amount> apples When I get <Red> red and <Green> green apples more Then I have a total of <Sum> apples Examples: | Start amount | Red | Green | Sum | | 2 | 3 | 4 | 9 | | 3 | 4 | 5 | 12 | """ appendScenarios(story1, text) @when(u"The serialize() method is called") def when(self): self.tree = self.catalogue.serialize() @then(u"An XML tree is output containing all epics, stories " u"and scenarios") def then(self): self.assertEqual( lxml.etree.tostring(self.tree, pretty_print=True).strip(), """\ <requirementscatalogue project="Test project" extractTime="2011-01-02T12:01:00"> <epic id="E1" title="First epic"> <story id="S1" title="First story" points="3" requirementStatus="open" priority="high"> <scenario name="Count some apples #01"> <given>I have 2 apples</given> <when>I get 3 red and 4 green apples more</when> <then>I have a total of 9 apples</then> </scenario> <scenario name="Count some apples #02"> <given>I have 3 apples</given> <when>I get 4 red and 5 green apples more</when> <then>I have a total of 12 apples</then> </scenario> </story> <story id="S2" title="Second story" points="3" requirementStatus="closed" requirementResolution="fixed" priority="high"/> </epic> <epic id="E2" title="Second epic"/> </requirementscatalogue>""".strip())
class RequirementsExtract(Scenario): @given("A requirements catalogue containing user requirements") def create(self): from corejet.core.model import RequirementsCatalogue from corejet.core.model import Epic, Story, Scenario, Step self.catalogue = RequirementsCatalogue( project="Test project", extractTime=datetime.datetime(2011, 1, 2, 12, 1, 0)) epic1 = Epic("E1", "First epic") self.catalogue.epics.append(epic1) epic2 = Epic("E2", "Second epic") self.catalogue.epics.append(epic2) story1 = Story("S1", "First story", points=3, status="open", priority="high", epic=epic1) epic1.stories.append(story1) story2 = Story("S2", "Second story", points=3, status="closed", resolution="fixed", priority="high", epic=epic1) epic1.stories.append(story2) scenario1 = Scenario( "First scenario", story=story1, givens=[Step("something", 'given')], whens=[Step("something happens", 'when')], thens=[ Step("do something", 'then'), Step("and something else", 'then') ], ) story1.scenarios.append(scenario1) scenario2 = Scenario( "Second scenario", story=story2, givens=[Step("something", 'given')], whens=[Step("something happens", 'when')], thens=[ Step("do something", 'then'), Step("and something else", 'then') ], ) story1.scenarios.append(scenario2) @when("The serialize() method is called") def serialize(self): self.tree = self.catalogue.serialize() @then( "An XML tree is output containing all epics, stories and scenarios" ) def checkOutput(self): self.assertEqual( lxml.etree.tostring(self.tree, pretty_print=True).strip(), """\ <requirementscatalogue project="Test project" extractTime="2011-01-02T12:01:00"> <epic id="E1" title="First epic"> <story id="S1" title="First story" points="3" requirementStatus="open" priority="high"> <scenario name="First scenario"> <given>something</given> <when>something happens</when> <then>do something</then> <then>and something else</then> </scenario> <scenario name="Second scenario"> <given>something</given> <when>something happens</when> <then>do something</then> <then>and something else</then> </scenario> </story> <story id="S2" title="Second story" points="3" requirementStatus="closed" requirementResolution="fixed" priority="high"/> </epic> <epic id="E2" title="Second epic"/> </requirementscatalogue>""".strip())
class Scenario(Scenario): @given(u"A requirements catalogue containing user requirements") def given(self): from corejet.core.model import RequirementsCatalogue, Epic, Story self.catalogue = RequirementsCatalogue( project="Test project", extractTime=datetime.datetime(2011, 1, 2, 12, 1, 0)) epic1 = Epic("E1", "First epic") self.catalogue.epics.append(epic1) epic2 = Epic("E2", "Second epic") self.catalogue.epics.append(epic2) story1 = Story("S1", "First story", points=3, status="open", priority="high", epic=epic1) epic1.stories.append(story1) story2 = Story("S2", "Second story", points=3, status="closed", resolution="fixed", priority="high", epic=epic1) epic1.stories.append(story2) text = """\ Background: Given some background And more background Scenario: First scenario Given something When something happens Then do something And something else But not this Scenario: Second scenario Given something When something happens Then do something And something else """ appendScenarios(story1, text) @when(u"The serialize() method is called") def when(self): self.tree = self.catalogue.serialize() @then(u"An XML tree is output containing all epics, stories " u"with background and scenarios") def then(self): self.assertEqual( lxml.etree.tostring(self.tree, pretty_print=True).strip(), """\ <requirementscatalogue project="Test project" extractTime="2011-01-02T12:01:00"> <epic id="E1" title="First epic"> <story id="S1" title="First story" points="3" requirementStatus="open" priority="high"> <given>some background</given> <given>more background</given> <scenario name="First scenario"> <given>something</given> <when>something happens</when> <then>do something</then> <then>something else</then> <then>not this</then> </scenario> <scenario name="Second scenario"> <given>something</given> <when>something happens</when> <then>do something</then> <then>something else</then> </scenario> </story> <story id="S2" title="Second story" points="3" requirementStatus="closed" requirementResolution="fixed" priority="high"/> </epic> <epic id="E2" title="Second epic"/> </requirementscatalogue>""".strip())
class Scenario(Scenario): @given(u"A requirements catalogue containing user requirements") def given(self): from corejet.core.model import RequirementsCatalogue, Epic, Story self.catalogue = RequirementsCatalogue( project="Test project", extractTime=datetime.datetime(2011, 1, 2, 12, 1, 0) ) epic1 = Epic("E1", "First epic") self.catalogue.epics.append(epic1) epic2 = Epic("E2", "Second epic") self.catalogue.epics.append(epic2) story1 = Story("S1", "First story", points=3, status="open", priority="high", epic=epic1) epic1.stories.append(story1) story2 = Story( "S2", "Second story", points=3, status="closed", resolution="fixed", priority="high", epic=epic1 ) epic1.stories.append(story2) text = """\ Background: Given some background And more background Scenario: First scenario Given something When something happens Then do something And something else But not this Scenario: Second scenario Given something When something happens Then do something And something else """ appendScenarios(story1, text) @when(u"The serialize() method is called") def when(self): self.tree = self.catalogue.serialize() @then(u"An XML tree is output containing all epics, stories " u"with background and scenarios") def then(self): self.assertEqual( lxml.etree.tostring(self.tree, pretty_print=True).strip(), """\ <requirementscatalogue project="Test project" extractTime="2011-01-02T12:01:00"> <epic id="E1" title="First epic"> <story id="S1" title="First story" points="3" requirementStatus="open" priority="high"> <given>some background</given> <given>more background</given> <scenario name="First scenario"> <given>something</given> <when>something happens</when> <then>do something</then> <then>something else</then> <then>not this</then> </scenario> <scenario name="Second scenario"> <given>something</given> <when>something happens</when> <then>do something</then> <then>something else</then> </scenario> </story> <story id="S2" title="Second story" points="3" requirementStatus="closed" requirementResolution="fixed" priority="high"/> </epic> <epic id="E2" title="Second epic"/> </requirementscatalogue>""".strip(), )
class Scenario(Scenario): @given(u"A requirements catalogue containing user requirements") def given(self): from corejet.core.model import RequirementsCatalogue, Epic, Story self.catalogue = RequirementsCatalogue(project="Test project", extractTime=datetime.datetime(2011, 1, 2, 12, 1, 0)) epic1 = Epic("E1", "First epic") self.catalogue.epics.append(epic1) epic2 = Epic("E2", "Second epic") self.catalogue.epics.append(epic2) story1 = Story("S1", "First story", points=3, status="open", priority="high", epic=epic1) epic1.stories.append(story1) story2 = Story("S2", "Second story", points=3, status="closed", resolution="fixed", priority="high", epic=epic1) epic1.stories.append(story2) text = """\ Scenario Outline: Count some apples Given I have <Start amount> apples When I get <Red> red and <Green> green apples more Then I have a total of <Sum> apples Examples: | Start amount | Red | Green | Sum | | 2 | 3 | 4 | 9 | | 3 | 4 | 5 | 12 | """ appendScenarios(story1, text) @when(u"The serialize() method is called") def when(self): self.tree = self.catalogue.serialize() @then(u"An XML tree is output containing all epics, stories " u"and scenarios") def then(self): self.assertEqual( lxml.etree.tostring(self.tree, pretty_print=True).strip(), """\ <requirementscatalogue project="Test project" extractTime="2011-01-02T12:01:00"> <epic id="E1" title="First epic"> <story id="S1" title="First story" points="3" requirementStatus="open" priority="high"> <scenario name="Count some apples #01"> <given>I have 2 apples</given> <when>I get 3 red and 4 green apples more</when> <then>I have a total of 9 apples</then> </scenario> <scenario name="Count some apples #02"> <given>I have 3 apples</given> <when>I get 4 red and 5 green apples more</when> <then>I have a total of 12 apples</then> </scenario> </story> <story id="S2" title="Second story" points="3" requirementStatus="closed" requirementResolution="fixed" priority="high"/> </epic> <epic id="E2" title="Second epic"/> </requirementscatalogue>""".strip())
class TestRunExtract(Scenario): @given("A requirements catalogue containing test results") def create(self): from corejet.core.model import RequirementsCatalogue from corejet.core.model import Epic, Story, Scenario, Step self.catalogue = RequirementsCatalogue(project="Test project", extractTime=datetime.datetime(2011,1,2,12,1,0), testTime=datetime.datetime(2011,1,2,12,5,0)) epic1 = Epic("E1", "First epic") self.catalogue.epics.append(epic1) epic2 = Epic("E2", "Second epic") self.catalogue.epics.append(epic2) story1 = Story("S1", "First story", points=3, status="open", priority="high", epic=epic1) epic1.stories.append(story1) story2 = Story("S2", "Second story", points=3, status="closed", resolution="fixed", priority="high", epic=epic1) epic1.stories.append(story2) scenario1 = Scenario("First scenario", story=story1, givens=[Step("something", 'given')], whens=[Step("something happens", 'when')], thens=[Step("do something", 'then'), Step("and something else", 'then')], status="pass", ) story1.scenarios.append(scenario1) scenario2 = Scenario("Second scenario", story=story2, givens=[Step("something", 'given')], whens=[Step("something happens", 'when')], thens=[Step("do something", 'then'), Step("and something else", 'then')], status="mismatch", ) story1.scenarios.append(scenario2) @when("The serialize() method is called") def serialize(self): self.tree = self.catalogue.serialize() @then("An XML tree is output containing all epics, stories and scenarios and their status") def checkOutput(self): self.assertEqual(lxml.etree.tostring(self.tree, pretty_print=True).strip(), """\ <requirementscatalogue project="Test project" extractTime="2011-01-02T12:01:00" testTime="2011-01-02T12:05:00"> <epic id="E1" title="First epic"> <story id="S1" title="First story" points="3" requirementStatus="open" priority="high"> <scenario name="First scenario" testStatus="pass"> <given>something</given> <when>something happens</when> <then>do something</then> <then>and something else</then> </scenario> <scenario name="Second scenario" testStatus="mismatch"> <given>something</given> <when>something happens</when> <then>do something</then> <then>and something else</then> </scenario> </story> <story id="S2" title="Second story" points="3" requirementStatus="closed" requirementResolution="fixed" priority="high"/> </epic> <epic id="E2" title="Second epic"/> </requirementscatalogue>""".strip())