7 |
Specifications Text
8 |
9 |
${results.getSpecificationResultsAsText()}
10 |
<%= HtmlReportHelper.formatHtmlReportElement(results, BehaviorStepType.SPECIFICATION)%>
11 |
12 |
--------------------------------------------------------------------------------
/src/main/resources/reports/easyb_report_stories_list_plain.tmpl:
--------------------------------------------------------------------------------
1 | <%
2 | import org.easyb.util.BehaviorStepType
3 | import org.easyb.report.HtmlReportHelper
4 | %>
5 |
6 |
7 |
Stories Text
8 |
9 |
<%= results.getScenarioResultsAsText() %>
10 |
<%= HtmlReportHelper.formatHtmlReportElement(results, BehaviorStepType.STORY)%>
11 |
12 |
--------------------------------------------------------------------------------
/src/main/resources/reports/easyb_spacer.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easyb/easyb-core/34033a2699ba7ce5cee1eb3303883a1f1fc7d2b1/src/main/resources/reports/easyb_spacer.gif
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/AnotherNoname.groovy:
--------------------------------------------------------------------------------
1 | package org.easyb
2 |
3 |
4 |
5 | given "a valid string with 6 characters", {
6 | var = "string"
7 | }
8 |
9 | when "length is called", {
10 | len = var.length()
11 | }
12 |
13 | then "the value returned should be 6", {
14 | len.is(6)
15 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/BeforeClosureSpecification.groovy:
--------------------------------------------------------------------------------
1 | package org.easyb;
2 |
3 | int value = 0
4 |
5 | before "increment the int value", {
6 | value++
7 | }
8 |
9 | it "should be 1 now", {
10 | value.shouldBe(1)
11 | }
12 |
13 | it "should be 2 now", {
14 | ensure(value) {isEqualTo2}
15 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/CamelCase.specification:
--------------------------------------------------------------------------------
1 | import org.easyb.util.CamelCaseConverter
2 |
3 |
4 |
5 | it "should return the whole word instead of trying to parse it", {
6 | cCase = new CamelCaseConverter("IRR")
7 | cCase.toPhrase().shouldEqual "IRR"
8 | }
9 |
10 | it "should return a properly parsed word", {
11 | iCase = new CamelCaseConverter("IRRIssue")
12 | iCase.toPhrase().shouldEqual "IRR issue"
13 | }
14 |
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/EasierDoesItSpecification.groovy:
--------------------------------------------------------------------------------
1 | package org.easyb;
2 |
3 |
4 | it "should support expressions in the ensure clause", {
5 | ensure(1 == 1)
6 | }
7 |
8 | it "should support other types of expressions in the ensure clause", {
9 | ensure("this".equals("this"))
10 | }
11 |
12 | it "should support more than one expression in the ensure clause", {
13 | ensure("this".equals("this") && "this" instanceof String)
14 | }
15 |
16 | it "should support negated expressions in the ensure clause", {
17 | ensure(!"this".equals("that"))
18 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/EnsureThrowsSpecification.groovy:
--------------------------------------------------------------------------------
1 | package org.easyb
2 |
3 | import org.easyb.exception.VerificationException
4 |
5 | it "should fail if an exception is not thrown", {
6 | failed = false
7 | try {
8 | ensureThrows(RuntimeException.class) {
9 | // If we don't throw an exception the spec should fail
10 | }
11 | failed = true
12 | } catch (VerificationException expected) {
13 | // Success
14 | }
15 | if (failed) {
16 | fail("The absence of an exception didn't fail the ensureThrows check")
17 | }
18 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/EnsuringHasStory.groovy:
--------------------------------------------------------------------------------
1 | package org.easyb
2 |
3 | import org.easyb.bdd.Person
4 |
5 | scenario "Person object with all properties defined", {
6 |
7 | given "Person object with all values set", {
8 | person = new Person("Jude", 41)
9 | }
10 |
11 | then "shouldHave should work with all properties", {
12 | person.shouldHave firstName: "Jude"
13 | and
14 | person.shouldHave age: 41
15 | }
16 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/FakeListener.groovy:
--------------------------------------------------------------------------------
1 | import org.easyb.BehaviorStep
2 | import org.easyb.listener.ExecutionListenerAdaptor
3 | import org.easyb.result.Result
4 |
5 | class FakeListener extends ExecutionListenerAdaptor {
6 | Result result
7 |
8 | void startStep(BehaviorStep step) {
9 |
10 | }
11 |
12 | void gotResult(Result result) {
13 | this.result = result
14 | }
15 |
16 | void stopStep() {
17 |
18 | }
19 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/IJustNeedClosure.story:
--------------------------------------------------------------------------------
1 |
2 |
3 | before "empty closure"
4 |
5 | after "empty closure"
6 |
7 | before_each "empty closure"
8 |
9 | after_each "empty closure"
10 |
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/Noname.groovy:
--------------------------------------------------------------------------------
1 | package org.easyb
2 |
3 | var = "string"
4 |
5 | it "should have a length of 6", {
6 | var.length().shouldBe(6)
7 | var.length().shouldBe 6
8 | }
9 |
10 | it "should not be null", {
11 | var.shouldNotBe null
12 | }
13 |
14 | it "should handle null objects", {
15 | value = null
16 |
17 | value.shouldBe null
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/SharedBehaviors.story:
--------------------------------------------------------------------------------
1 | shared_behavior "shared behaviors", {
2 | given "a string", {
3 | var = ""
4 | }
5 |
6 | when "the string is hello world", {
7 | var = "hello world"
8 | }
9 | }
10 |
11 | scenario "first scenario", {
12 | it_behaves_as "shared behaviors"
13 |
14 | then "the string should start with hello", {
15 | var.shouldStartWith "hello"
16 | }
17 | }
18 |
19 | scenario "second scenario", {
20 | it_behaves_as "shared behaviors"
21 |
22 | then "the string should end with world", {
23 | var.shouldEndWith "world"
24 | }
25 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/WhenEvaluatingGivenClosure.specification:
--------------------------------------------------------------------------------
1 | import org.easyb.StoryBinding
2 |
3 | it "should notify listener of exceptions", {
4 | def listener = new FakeListener()
5 |
6 | def story = StoryBinding.getBinding(listener, null)
7 | new GroovyShell(story).evaluate('''
8 | given "", 0, "an exception is thrown", {
9 | throw new RuntimeException('test')
10 | }
11 | ''');
12 |
13 | story.replaySteps(true)
14 |
15 | listener.result.cause.message.shouldBe 'test'
16 | }
17 |
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/WhenEvaluatingWhenClosure.specification:
--------------------------------------------------------------------------------
1 | import org.easyb.StoryBinding
2 |
3 | it "should notify listener of exceptions", {
4 | def listener = new FakeListener()
5 |
6 | def story = StoryBinding.getBinding(listener, null)
7 |
8 | new GroovyShell(story).evaluate('''
9 | when "", 0, "an exception is thrown", {
10 | throw new RuntimeException('test')
11 | }
12 | ''');
13 |
14 | story.replaySteps(true)
15 |
16 | listener.result.cause.message.shouldBe 'test'
17 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/WhenStartingBehaviorStep.specification:
--------------------------------------------------------------------------------
1 | import org.easyb.BehaviorStep
2 | import org.easyb.BehaviorStepStack
3 | import org.easyb.listener.ExecutionListenerAdaptor
4 | import org.easyb.util.BehaviorStepType
5 |
6 | def stack
7 | def listener
8 |
9 | before "create behavior step stack", {
10 | listener = new ExecutionListenerAdaptor()
11 | stack = new BehaviorStepStack(listener)
12 | }
13 |
14 | it "should create step and push step onto stack", {
15 | stack.startStep(BehaviorStepType.SCENARIO, 'description')
16 | BehaviorStep lastStep = stack.lastStep()
17 | lastStep.shouldNotBe null
18 | }
19 |
20 | it "should notify listener"
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/WhenStoppingBehaviorStep.specification:
--------------------------------------------------------------------------------
1 | import org.easyb.BehaviorStepStack
2 | import org.easyb.listener.ExecutionListenerAdaptor
3 | import org.easyb.util.BehaviorStepType
4 |
5 | def stack
6 | def listener
7 |
8 | before "create behavior step stack", {
9 | listener = new ExecutionListenerAdaptor()
10 | stack = new BehaviorStepStack(listener)
11 |
12 | }
13 |
14 | it "should pop step from stack", {
15 | stack.startStep(BehaviorStepType.SCENARIO, 'description')
16 | stack.stopStep()
17 |
18 | stack.lastStep().shouldNotBe null
19 | and
20 | stack.lastStep().stepType.shouldBe BehaviorStepType.SCENARIO
21 | }
22 |
23 | it "should notify listener"
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/WithdrawingFunds.story:
--------------------------------------------------------------------------------
1 | scenario "withdrawing funds", {
2 | given "an account with a \$100 balance"
3 | when "an account holder withdraws \$75"
4 | then "the account balance should be \$25"
5 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/ant/WhenRunningEasybWithAnt.specification:
--------------------------------------------------------------------------------
1 | it "should run without error", {
2 | // This is verified in the build for easyb itself
3 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/issues/ContentsInCollection.story:
--------------------------------------------------------------------------------
1 |
2 | scenario "easyb should find contents in a collection", {
3 |
4 | given "a collection of strings", {
5 | uris = ["http://acme.com/w018/widget/4000000001/200901/AQSN_ESTB/PREM/ORIG/1000",
6 | "http://acme.com/w018/widget/4000000001/200901/PFP_CSLDN_XFER/PREM/ORIG/1000",
7 | "http://acme.com/w018/widget/4000000001/200901/PFP_CSLDN_RCPTR/PREM/ORIG/1000",
8 | "http://acme.com/w018/widget/4000000001/200901/AMRT_AMRT_AM_RR/PREM/ACCD_AMRT/10"]
9 |
10 | }
11 |
12 | then "easyb should find items in it" , {
13 | uris.shouldHave "http://acme.com/w018/widget/4000000001/200901/AQSN_ESTB/PREM/ORIG/1000"
14 | }
15 |
16 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/issues/DoesNotContain.story:
--------------------------------------------------------------------------------
1 | scenario "sub-strings should not match doesNotContain", {
2 | given "a list of strings, ['a','ab','abc']", {
3 | l = ['a', 'ab', 'abc']
4 | }
5 |
6 | then "list should not contain a simple 'c'", {
7 | l.shouldNotHave('c')
8 | ensure(l) {
9 | doesNotContain('c')
10 | }
11 | }
12 | }
13 |
14 |
15 | scenario "sub-strings should match doesContain", {
16 | given "a list of strings, ['a','ab','abc']", {
17 | l = ['a', 'ab', 'abc']
18 | }
19 |
20 | then "list should contain a simple 'a'", {
21 | l.shouldHave('a')
22 | ensure(l) {
23 | contains('a')
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/issues/Issue103.specification:
--------------------------------------------------------------------------------
1 | import org.easyb.exception.VerificationException
2 |
3 | before "setup string", {
4 | var = "hello world"
5 | }
6 |
7 | after "tear down", {
8 | var = 24
9 | }
10 |
11 | it "should be hello world", {
12 | var.shouldBe "hello world"
13 | }
14 |
15 | if(var != 24){
16 | throw new VerificationException("after closure doesn't appear to be working!")
17 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/issues/Issue109.story:
--------------------------------------------------------------------------------
1 | scenario "Non-Gold level customer with \$100 or more" , {
2 | given "a non-Gold level customer"
3 | when "they have \$100 or more in their shopping cart"
4 | then "they should receive a \$10 discount"
5 | and "they should be emailed a coupon"
6 | }
7 |
8 | scenario "another Non-Gold level customer with \$100 or more" , {
9 | given "another non-Gold level customer"
10 | when "they have another \$100 or more in their shopping cart"
11 | then "they should receive another \$10 discount"
12 | then "they should be emailed another coupon"
13 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/issues/Issue110and111Story.groovy:
--------------------------------------------------------------------------------
1 | scenario "ensure shouldStartWith works like startsWith", {
2 | given "a string", {
3 | var = "hello world"
4 | }
5 |
6 | then "should start with hello", {
7 | var.shouldStartWith "hello"
8 | }
9 | }
10 |
11 | scenario "ensure shouldEndWith works like endsWith", {
12 | given "a string", {
13 | var = "hello world"
14 | }
15 |
16 | then "should end with word", {
17 | var.shouldEndWith "world"
18 | }
19 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/issues/Issue17.story:
--------------------------------------------------------------------------------
1 | package org.easyb.bdd.issues //package needed for eclipse?
2 |
3 | given "a file ending in .story", {
4 | value = 12 + 5
5 | }
6 |
7 | then "easyb should excute is as normal", {
8 | value.shouldBe 17
9 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/issues/Issue177.story:
--------------------------------------------------------------------------------
1 |
2 | ignore {
3 | scenario "this is purposely a broken scenario", {
4 | given "some variable with a value", {
5 | val = 12
6 | }
7 | then "to force an error, one should verify it is not 12", {
8 | val.shouldNotEqual 12
9 | }
10 | }
11 |
12 | scenario "another purposely a broken scenario", {
13 | given "some variable with a value", {
14 | val = 13
15 | }
16 | then "to force an error, one should verify it is not 12", {
17 | val.shouldNotEqual 13
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/issues/Issue18Story.groovy:
--------------------------------------------------------------------------------
1 | package org.easyb.bdd.issues
2 |
3 | scenario "all subparts have no closures defined", {
4 |
5 | given "no closure"
6 | when "easyb is invoked with this story"
7 | then "it should accept this as an unimplemented closure"
8 | and
9 | then "easyb should not count this as a successful scenario, but a pending one"
10 |
11 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/issues/Issue23.story:
--------------------------------------------------------------------------------
1 | package org.easyb.bdd.issues
2 |
3 | scenario "shouldBe should accept negative numbers", {
4 |
5 | given "a negative number", {
6 | negint = -3
7 | }
8 |
9 | then "the value should be an Integer", {
10 | negint.shouldBeAn(Integer)
11 | }
12 |
13 | and
14 |
15 | then "it should be -3", {
16 | negint.shouldBe(-3)
17 | //this doesn't work-- results in a property call
18 | //negint.shouldBe -3
19 | }
20 |
21 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/issues/Issue240StoryToRun.story:
--------------------------------------------------------------------------------
1 | package org.easyb.bdd.issues
2 |
3 | shared_behavior "Division wonderland", {
4 | then "we expect an error", {
5 | (10 / divisor).shouldBe expectedResult
6 | }
7 | and "we expect something nice", {
8 | true.shouldBe true
9 | }
10 | }
11 |
12 | scenario "Call a shared behaviour and die ...", {
13 | given "We set up our expectations", {
14 | divisor = System.getProperty("org.easyb.bdd.issues.Issue240", "10").toInteger()
15 | expectedResult = 1
16 | }
17 | it_behaves_as "Division wonderland"
18 |
19 | then "we expect nothing", {
20 | expectedResult.shouldBe 1
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/issues/Issue78.story:
--------------------------------------------------------------------------------
1 | import org.easyb.exception.VerificationException
2 |
3 | description "this issue relates to improper reporting of pending scenarios"
4 |
5 | int initcount = easybResults().getPendingScenarioCount()
6 |
7 | scenario "this is technically a pending scenario", {
8 |
9 | }
10 |
11 | scenario "this scenario is not pending", {
12 | given "that someone defined a scenario with an empty closure"
13 | then "easyb should consider that a pending one"
14 | }
15 |
16 | runScenarios()
17 |
18 | if (easybResults().getPendingScenarioCount() > (initcount + 2)) {
19 | throw new VerificationException('Pending scenarios count not correct')
20 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/issues/Issue87.story:
--------------------------------------------------------------------------------
1 |
2 | ignore all
3 |
4 | scenario "this is purposely a broken scenario", {
5 | given "some variable with a value", {
6 | val = 12
7 | }
8 | then "to force an error, one should verify it is not 12", {
9 | val.shouldNotEqual 12
10 | }
11 | }
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/issues/Issue87Selective.story:
--------------------------------------------------------------------------------
1 |
2 |
3 | ignore "this is purposely a broken scenario"
4 |
5 | scenario "this is purposely a broken scenario", {
6 | given "some variable with a value", {
7 | val = 12
8 | }
9 | then "to force an error, one should verify it is not 12", {
10 | val.shouldNotEqual 12
11 | }
12 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/issues/IssueNotAndNullStory.groovy:
--------------------------------------------------------------------------------
1 | package org.easyb.bdd.issues
2 |
3 | import org.easyb.exception.VerificationException
4 |
5 | scenario "should not should work with null values", {
6 |
7 | given "a null value", {
8 | val = null
9 | }
10 |
11 | then "verifying it isn't null should work", {
12 | try {
13 | val.shouldNotBe null
14 | } catch (VerificationException e) {
15 | e.message.shouldBe "expected values to differ but both were null"
16 | }
17 | }
18 |
19 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/issues/OrAndQuestions.story:
--------------------------------------------------------------------------------
1 | scenario "easyb can and should support expressions", {
2 |
3 | given "a value of 3", {
4 | value = 3
5 | }
6 | then "an expression should evaluate to true", {
7 | (value >=0 && value <=6).shouldBe true
8 | }
9 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/issues/RunningPendingCategories.story:
--------------------------------------------------------------------------------
1 |
2 | tags "sanity"
3 |
4 | scenario "User A wants to work with a lab mdta, user b wants to use an prod mdta",{
5 | given "blah",{
6 |
7 | }
8 |
9 | when "blah", {
10 |
11 | }
12 |
13 | then "blah", {
14 |
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/issues/space in path/Issue86.story:
--------------------------------------------------------------------------------
1 | scenario "files with spaces in path should still pass", {
2 | given "this file is in a path with spaces", {
3 | inconsequentialValue = 12 + 5
4 | }
5 |
6 | then "easyb should excute is as normal", {
7 | inconsequentialValue.shouldBe 17
8 | }
9 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/money/MoneyStory.groovy:
--------------------------------------------------------------------------------
1 | package org.easyb.bdd.money
2 |
3 | description "This story is about currency management"
4 |
5 | narrative "this string is required for now", {
6 | as_a "person who uses money"
7 | i_want "to be able to add them together"
8 | so_that "that I can become rich (and wierd)"
9 | }
10 |
11 | scenario "two moneys of the same currency are added", {
12 |
13 | given "one money object is added to another", {
14 | total = new Money(12, "CHF").add(new Money(14, "CHF"))
15 | }
16 |
17 | then "the total amount should be the sum of the two", {
18 | total.amount().shouldBe 26
19 | }
20 |
21 | }
22 |
23 | scenario "two moneys of different currencies are added", {
24 |
25 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/nounderscores/NarrativeWithoutUnderscores.story:
--------------------------------------------------------------------------------
1 | package org.easyb.bdd.nounderscores
2 | description "this is a prototype story for using narratives"
3 |
4 | narrative "this feature is for easyb users", {
5 | as a "analyst or domain expert or developer"
6 | i want "to document the persona, etc of a user acting in the story"
7 | so that "the story/scenario is documented more fully"
8 | }
9 |
10 | scenario "this is a simple scenario" , {
11 | given "something", {
12 | foo = "bar"
13 | }
14 | when "something else happends", {
15 | val = foo[0]
16 | }
17 | then "something should be validated" , {
18 | val.shouldBe "b"
19 | }
20 | }
21 |
22 | scenario "one pending scenario for no reason at all"
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/nounderscores/SharedBehaviorWithoutUnderscores.story:
--------------------------------------------------------------------------------
1 | package org.easyb.bdd.nounderscores
2 | shared behavior "shared behaviors", {
3 | given "a string", {
4 | var = ""
5 | }
6 |
7 | when "the string is hello world", {
8 | var = "hello world"
9 | }
10 | }
11 |
12 | scenario "first scenario", {
13 | it behaves as "shared behaviors"
14 |
15 | then "the string should start with hello", {
16 | var.shouldStartWith "hello"
17 | }
18 | }
19 |
20 | scenario "second scenario", {
21 | it behaves as "shared behaviors"
22 |
23 | then "the string should end with world", {
24 | var.shouldEndWith "world"
25 | }
26 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/prototype/AndChainedFeature.story:
--------------------------------------------------------------------------------
1 | package org.easyb.bdd.prototype
2 |
3 | scenario "easyb should support and chaining", {
4 |
5 | given "an integer value of 10", {
6 | value1 = 10
7 | }
8 |
9 | and "given another integer value of 5", {
10 | value2 = 5
11 | }
12 |
13 | when "the first integer value has 10 added to it", {
14 | value1 += 10
15 | }
16 |
17 | and "when the second integer value has 12 added to it", {
18 | value2 += 12
19 | }
20 |
21 | then "the first variable should be equal to 20", {
22 | value1.shouldBe 20
23 | }
24 |
25 | and "then the second value should be equal to 17", {
26 | value2.shouldBe 17
27 | }
28 | }
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/prototype/EnhancedEnsure.groovy:
--------------------------------------------------------------------------------
1 | package org.easyb.bdd.prototype
2 |
3 | import org.easyb.exception.VerificationException
4 |
5 | class EnhancedEnsure {
6 |
7 | def verify
8 |
9 | void isPositive() {
10 | if(verify < 0){
11 | throw new VerificationException("value of ${verify} wasn't postitive")
12 | }
13 | }
14 |
15 | def getProperty(String property) {
16 | if(property == "isPositive"){
17 | isPositive()
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/prototype/ExceptionalOccurrence.story:
--------------------------------------------------------------------------------
1 |
2 |
3 | //ignore all
4 |
5 | scenario "this generates an exception", {
6 | given "a null object", {
7 | foo = null
8 | }
9 | then "doing something with it should blow things up", {
10 | foo.blowmeup()
11 | }
12 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/prototype/ExtendedCategories.groovy:
--------------------------------------------------------------------------------
1 | package org.easyb.bdd.prototype
2 |
3 | import org.easyb.BehaviorCategory
4 |
5 | public class ExtendedCategories {
6 | static void betterBe(Object self, value) {
7 | BehaviorCategory.shouldBe(self, value)
8 | }
9 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/prototype/MixinExample.story:
--------------------------------------------------------------------------------
1 |
2 | //import org.easyb.BehaviorCategory
3 | //import org.easyb.bdd.prototype.ExtendedCategories
4 | //
5 | //BehaviorCategory.mixin ExtendedCategories
6 |
7 | using "BetterBe"
8 |
9 | scenario "mixins should work normally", {
10 | given "a definition of a new method" , {
11 | var = "blah"
12 | }
13 | then "mixing it into easyb should work", {
14 | var.betterBe "blah"
15 | var.shouldBe "blah" //original stuff works the same still...
16 | }
17 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/prototype/NarrativeUsage.story:
--------------------------------------------------------------------------------
1 |
2 | description "this is a prototype story for using narratives"
3 |
4 | narrative "this feature is for easyb users", {
5 | as_a "analyst or domain expert or developer"
6 | i_want "to document the persona, etc of a user acting in the story"
7 | so_that "the story/scenario is documented more fully"
8 | }
9 |
10 | scenario "this is a simple scenario" , {
11 | given "something", {
12 | foo = "bar"
13 | }
14 | when "something else happends", {
15 | val = foo[0]
16 | }
17 | then "something should be validated" , {
18 | val.shouldBe "b"
19 | }
20 | }
21 |
22 | scenario "one pending scenario for no reason at all"
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/prototype/UsingButInsteadOfAnd.story:
--------------------------------------------------------------------------------
1 | scenario "but should act just like and", {
2 | given "I have two sons"
3 | then "they are both boys"
4 | but "they have different ages"
5 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/reporting/FailureReport.story:
--------------------------------------------------------------------------------
1 | package org.easyb.bdd.reporting
2 |
3 | scenario "this scenario will fail!", {
4 |
5 | given "a false variable", {
6 | val = false
7 | }
8 |
9 | then "easyb will report a failure if should is true", {
10 | val.shouldBe true
11 | }
12 |
13 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/reporting/html/PassingPendingFailing.specification:
--------------------------------------------------------------------------------
1 | before "set up", {
2 | var = true
3 | }
4 |
5 | after "tear down", {
6 | var = false
7 | }
8 |
9 | it "should be passing", {
10 | var.shouldBe true
11 | }
12 |
13 | it "should be pending"
14 |
15 | it "should be failing", {
16 | var.shouldBe false
17 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/reporting/html/PassingPendingFailingStory.story:
--------------------------------------------------------------------------------
1 | scenario "pending scenario"
2 |
3 | scenario "failing scenario", {
4 | then "1 does not equal 0 should fail", {
5 | 1.shouldEqual 0
6 | }
7 | }
8 |
9 | scenario "passing scenario", {
10 | then "1 should equal 1", {
11 | 1.shouldEqual 1
12 | }
13 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/reporting/html/ScenarioWithExamples.story:
--------------------------------------------------------------------------------
1 | package org.easyb.bdd.reporting.html
2 |
3 |
4 | examples "names and favorite colors", {
5 | name = ["jack", "jill", "jane"]
6 | favoriteColor = ["red", null, "blue"]
7 | }
8 |
9 | scenario "Favorite colors", {
10 | given "a person called #name and an unknown field called #unknownField", {
11 | }
12 | when "the application looks up the favorite color of #name", {
13 | }
14 | then "the favorite color of #name should be #favoriteColor", {
15 | }
16 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/reporting/txt/NestedScenarios.story:
--------------------------------------------------------------------------------
1 | scenario "parent scenario", {
2 |
3 | scenario "child scenario", {
4 |
5 | then "1 should equal 1", {
6 | 1.shouldEqual 1
7 | }
8 |
9 | }
10 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/reporting/txt/ScenarioWithFailingExamples.story:
--------------------------------------------------------------------------------
1 | package org.easyb.bdd.reporting.txt
2 |
3 |
4 |
5 | examples "names and favorite colors", {
6 | name = ["jack", "jill", "jane"]
7 | favoriteColor = ["red", null, "blue"]
8 | }
9 |
10 | scenario "Favorite colors", {
11 | given "a person called #name", {
12 | }
13 | when "the application looks up the favorite color of #name", {
14 | }
15 | then "the favorite color of #name should be #favoriteColor", {
16 | }
17 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/reporting/xml/NarrativeMappingScenario.story:
--------------------------------------------------------------------------------
1 | package org.easyb.bdd.reporting.xml
2 |
3 | narrative "Should be in narrative description", {
4 | as_a "Should be in narrative role description"
5 | i_want "Should be in narrative feature description"
6 | so_that "Should be in narrative benefit description"
7 | }
8 |
9 | scenario "This scenario is in a story that contains a narrative for testing XML report mapping", {
10 | def dada
11 |
12 | given "We initialize a variable", {
13 | dada = true
14 | }
15 | then "its value has the expected value", {
16 | dada.shouldBe true
17 | }
18 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/specification/PendingSpecification.groovy:
--------------------------------------------------------------------------------
1 | package org.easyb.bdd.specification
2 |
3 | it "should show up as a pending specification"
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/specification/queue/QueueSpecification.groovy:
--------------------------------------------------------------------------------
1 | package org.easyb.bdd.specification.queue
2 |
3 | import org.easyb.bdd.Queue
4 |
5 | description "This is how a Queue must work"
6 |
7 | before "initialize the queue for each spec", {
8 | queue = new Queue()
9 | }
10 |
11 | it "should dequeue item just enqueued", {
12 | queue.enqueue(2)
13 | queue.dequeue().shouldBe(2)
14 | }
15 |
16 | it "should throw an exception when null is enqueued", {
17 | ensureThrows(RuntimeException.class) {
18 | queue.enqueue(null)
19 | }
20 | }
21 |
22 | it "should dequeue items in same order enqueued", {
23 | [1..5].each {val ->
24 | queue.enqueue(val)
25 | }
26 | [1..5].each {val ->
27 | queue.dequeue().shouldBe(val)
28 | }
29 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/specification/stringutil/StringUtilSpecification.groovy:
--------------------------------------------------------------------------------
1 | package org.easyb.bdd.specification.stringutil
2 |
3 | import org.easyb.bdd.StringUtilPartial
4 |
5 | it "should return null for null input to trim", {
6 | StringUtilPartial.trim(null).shouldBe null
7 | }
8 |
9 | it "should return the string without whitespace at either the end", {
10 | StringUtilPartial.trim(" somestring ").shouldNotBe null
11 | StringUtilPartial.trim(" somestring ").shouldBe "somestring"
12 | }
13 |
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/specification/zip/ZipCodeSpecification.groovy:
--------------------------------------------------------------------------------
1 | package org.easyb.bdd.specification.zip
2 |
3 | import org.easyb.bdd.zip.ZipCodeValidator
4 |
5 | before "initialize zipcodevalidator instance", {
6 | zipvalidate = new ZipCodeValidator();
7 | }
8 |
9 | it "should deny invalid zip codes", {
10 | ["221o1", "2210", "22010-121o"].each {zip ->
11 | zipvalidate.validate(zip).is false
12 | }
13 | }
14 |
15 | it "should accept valid zip codes", {
16 | ["22101", "22100", "22010-1210"].each {zip ->
17 | zipvalidate.validate(zip).shouldBe true
18 | }
19 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/story/stack/TwoValueStackStory.groovy:
--------------------------------------------------------------------------------
1 | package org.easyb.bdd.story.stack
2 |
3 | import org.easyb.bdd.Stack
4 |
5 | scenario "pop returns last item", {
6 | given "a stack with two values", {
7 | stack = new Stack()
8 | push1 = "foo"
9 | push2 = "bar"
10 | stack.push(push1)
11 | stack.push(push2)
12 | }
13 |
14 | when "pop is called", {
15 | popVal = stack.pop()
16 | }
17 |
18 | then "the last item pushed should be returned", {
19 | popVal.shouldBe push2
20 | }
21 |
22 | and
23 |
24 | then "the stack should not be empty", {
25 | stack.empty.shouldBe false
26 | }
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/bdd/story/zip/ZipCodeStory.groovy:
--------------------------------------------------------------------------------
1 | package org.easyb.bdd.story.zip
2 |
3 | import org.easyb.bdd.zip.ZipCodeValidator
4 |
5 | given "an invalid zip code", {
6 | invalidzipcode = "221o1"
7 | }
8 |
9 | and
10 |
11 | given "the zipcodevalidator is initialized", {
12 | zipvalidate = new ZipCodeValidator();
13 | }
14 |
15 | when "validate is invoked with the invalid zip code", {
16 | value = zipvalidate.validate(invalidzipcode)
17 | }
18 |
19 | then "the validator instance should return false", {
20 | value.shouldBe(false)
21 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/delegates/EasybNarrative.story:
--------------------------------------------------------------------------------
1 | package org.easyb.delegates
2 |
3 | description "an easyb description would be nice"
4 |
5 | narrative "Easyb Narrative Story", {
6 | as_a "strange person"
7 | i_want "to weird people out"
8 | so_that "i can be funny"
9 | }
10 |
11 | scenario "blah blah", {
12 |
13 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/domain/RegExCatHelper.story:
--------------------------------------------------------------------------------
1 | import org.easyb.util.TagRegExHelper
2 |
3 | scenario "using tag helper", {
4 | given "a more complex string with a group", {
5 | lots = """tag ["bazzy","bar"]"""
6 | }
7 | then "using tag helper should return true or false", {
8 | helper = new TagRegExHelper()
9 | list1 = helper.getTags(lots)
10 | list1[0].shouldBe "bazzy"
11 | list1[1].shouldBe "bar"
12 | }
13 | }
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/listener/WhenCollectingResults.specification:
--------------------------------------------------------------------------------
1 | import org.easyb.BehaviorStep
2 | import org.easyb.listener.ResultsCollector
3 | import org.easyb.util.BehaviorStepType
4 |
5 | it "should not modify the supplied behavior step", {
6 | try {
7 | def step = new BehaviorStep(BehaviorStepType.SCENARIO, "Test step")
8 | def collector = new ResultsCollector()
9 | collector.startStep step
10 | step.getParentStep().shouldBe null
11 | } catch (Exception e) {
12 | e.printStackTrace()
13 | }
14 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/plugin/BetterBePlugin.groovy:
--------------------------------------------------------------------------------
1 | package org.easyb.plugin
2 |
3 | import org.easyb.bdd.prototype.ExtendedCategories
4 | import org.easyb.plugin.BasePlugin
5 |
6 | class BetterBePlugin extends BasePlugin {
7 |
8 | public String getName() {
9 | return "BetterBe";
10 | }
11 |
12 | public Object beforeStory(Binding binding) {
13 | Object.mixin ExtendedCategories
14 | }
15 |
16 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/plugin/ExampleWrapper.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by IntelliJ IDEA.
3 | * User: richard
4 | * Date: Jun 12, 2010
5 | * Time: 10:46:16 AM
6 | */
7 | package org.easyb.plugin;
8 |
9 | /**
10 | * doesn't hold anything, just a dummy so it doesn't match a Map or Closure
11 | */
12 | public class ExampleWrapper {
13 |
14 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/plugin/ExampleWrapperDataParser.groovy:
--------------------------------------------------------------------------------
1 | package org.easyb.plugin;
2 |
3 | public class ExampleWrapperDataParser implements ExampleDataParser {
4 |
5 | def boolean processData(Object data, Object closure, Object binding) {
6 |
7 | if ( data instanceof ExampleWrapper ) {
8 | def map = [a:1, b:2, c:3]
9 | closure(map)
10 | map = [a:2, b:4, c:6]
11 | closure(map)
12 |
13 | return true
14 | }
15 |
16 | return false
17 | }
18 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/plugin/ExampleWrapperTest.story:
--------------------------------------------------------------------------------
1 | package org.easyb.plugin
2 |
3 | where "we are using example wrapper", new ExampleWrapper()
4 |
5 | before "how many times", {
6 | times = 0
7 | total = 0
8 | }
9 |
10 | scenario "example wrapper test #a #b #c", {
11 | when "totals", {
12 | total += (a+b+c)
13 | }
14 | then "a + b should be c", {
15 | (a+b).shouldBe c
16 | }
17 | }
18 |
19 | after "checking results", {
20 | then "totals", {
21 | total.shouldBe 18
22 | }
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/plugin/NoPlugin.story:
--------------------------------------------------------------------------------
1 |
2 |
3 | scenario "a plugin missing should throw a RuntimeException", {
4 | then "throws", {
5 | ensureThrows(RuntimeException) {
6 | using 'wibble'
7 | }
8 | }
9 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/plugin/WhenLocatingPlugin.specification:
--------------------------------------------------------------------------------
1 | import org.easyb.plugin.PluginLocator
2 |
3 | PluginLocator locator = new PluginLocator()
4 |
5 | it 'should find service by name', {
6 | // remember these are tests for testing that the locator works.. (eat the dog food)
7 | // this approach shouldn't be used when you want to load a given plugin to use in a story
8 | //
9 | // for that use the 'using' keyword @See -> StoryLifeCycle.story
10 | locator.findPluginWithName('test').name.shouldBe 'test'
11 | }
12 |
13 | it 'should throw exception if service not found', {
14 | ensureThrows(RuntimeException) {
15 | locator.findPluginWithName('unknown')
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/reporting_tags/InsertReportingTagsInto.story:
--------------------------------------------------------------------------------
1 |
2 | extension "jiraReportingPlugin"
3 | // inserts extra syntax into story
4 |
5 | scenario "paying a customer in arrears takes them out of arrears", {
6 | jira(['id':"CSS-1574", 'description':"This should be in the report"]) // needs the brackets
7 | given "A Customer", {
8 | customerId = 5
9 | jira([id:"some text", description:"some other text"])
10 | }
11 | when "We pay an amount", {
12 | // this should come from an autoloaded syntax extension
13 | exec {"1"+"1"}
14 | }
15 | then "They aren't in arrears any longer"
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/reporting_tags/InsertReportingTagsIntoSpec.specification:
--------------------------------------------------------------------------------
1 |
2 | extension "jiraReportingPlugin"
3 | // inserts extra syntax into spec
4 |
5 | jira(['id':"CSS-1574", 'description':"This should be in the report"]) // needs the brackets
6 |
7 | it "should have a jire tag inside", {
8 | jira([id:"some text", description:"some other text"])
9 | }
10 |
11 | exec { "1" + "1" }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/shared/sharedSpec.specification:
--------------------------------------------------------------------------------
1 |
2 |
3 | // does this even make sense???
4 | shared_specs "specs.shared"
5 |
6 | it "should still be 20", {
7 | beforeVal.shouldBe 20
8 | }
9 |
10 | before "re-set the before", {
11 | beforeVal = 10
12 | }
13 |
14 | it "should now be 10", {
15 | beforeVal.shouldBe 10
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/shared/sharedTest.story:
--------------------------------------------------------------------------------
1 |
2 |
3 | shared_stories "stories"
4 |
5 | scenario "We should be able to use a shared story", {
6 | it_behaves_as "my shared story"
7 |
8 | when "we add a number to beforeVal", {
9 | beforeVal += 50
10 | }
11 |
12 | // this doesn't follow on, but hey
13 | then "state should be set", {
14 | number.shouldBe 60
15 | }
16 | }
17 |
18 | runScenarios()
19 |
20 | assert number == 60
21 | assert beforeVal == 70
22 |
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/shared/specs.shared:
--------------------------------------------------------------------------------
1 |
2 |
3 | before "this is a shared before", {
4 | beforeVal = 20
5 | }
6 |
7 | it "this is a shared spec", {
8 | beforeVal.shouldBe 20
9 | beforeVal += 20
10 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/shared/stories.shared:
--------------------------------------------------------------------------------
1 |
2 |
3 | shared_behavior "my shared story", {
4 | given "a number", {
5 | number = 60
6 | }
7 | }
8 |
9 | before "this should operate before anything happens", {
10 | given "an initial setting", {
11 | beforeVal = 20
12 | }
13 | }
14 |
15 | after "and this should happen afterwards", {
16 | then "beforeVal should be more", {
17 | beforeVal.shouldBeGreaterThan 20
18 | }
19 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/where/ExampleAsIgnoredScenario.story:
--------------------------------------------------------------------------------
1 | package org.easyb.where
2 | /*
3 | Example tests a map at the story level
4 | */
5 |
6 | ignore all
7 |
8 | scenario "This scenario should not be run", {
9 | then "It should blow up if it is run", {
10 | }
11 | where "Number examples with '#text' and #number", { throw new org.easyb.exception.VerificationException("shouldn't eval closure")}
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/where/Issue202Example.story:
--------------------------------------------------------------------------------
1 | scenario "strange txt report with a clause where having 2 variables (defect or misuse ?)",{
2 | where "2 variables having 2 values", [x:[1,2], y:[1,2]]
3 |
4 | when "i do anything, variables being x=#x and y=#y", {
5 | println "${x} ${y}"
6 | }
7 | then "shouldn't easyb report 2 scenarios ? instead of reporting 4 scenarios including 2 ignored ones ?", {
8 | x.shouldEqual y
9 | }
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/where/NoDataIgnored.story:
--------------------------------------------------------------------------------
1 |
2 | /**
3 | * this scenario might happen if a method call returns null for data and is more likely
4 | * where a block of scenarios get executed if there is data, otherwise they get ignored.
5 | */
6 |
7 |
8 | where "we only have a where description", null, {
9 |
10 | }
11 |
12 | examples "we only have a example desc", null, {
13 |
14 | }
15 |
16 |
17 | where "we only have a where description", null
18 |
19 | examples "we only have a example desc", null
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/where/TieredSharedScenarios.story:
--------------------------------------------------------------------------------
1 |
2 |
3 | before "it all!", {
4 | total = 0
5 | }
6 |
7 | // this is in top level context
8 | shared_behavior "shared", {
9 | then "add it up", {
10 | total += amount
11 | }
12 | }
13 |
14 | // this will be in its own context because of the where clause
15 | scenario "wibble #amount", {
16 | it_behaves_as "shared"
17 |
18 | where "give some amounts", [amount:[1,2,3]]
19 | }
20 |
21 |
22 | after "should be 6", {
23 | then "should be 6", {
24 | total.shouldBe 6
25 | }
26 | }
--------------------------------------------------------------------------------
/src/test/groovy/org/easyb/where/WeirdGivenSyntaxInWhere.story:
--------------------------------------------------------------------------------
1 |
2 | before "make total", {
3 | total = 0
4 | }
5 |
6 | where "weird syntax data", [amount:[1,2,3]], {
7 | then "amount #amount", {
8 | total += amount
9 | }
10 | }
11 |
12 | after "should be 6", {
13 | then "should be 6", {
14 | total.shouldBe 6
15 | }
16 | }
--------------------------------------------------------------------------------
/src/test/java/org/easyb/bdd/Person.java:
--------------------------------------------------------------------------------
1 | package org.easyb.bdd;
2 |
3 | public class Person {
4 |
5 | private String firstName;
6 | private int age;
7 |
8 | public Person(String firstName, int age) {
9 | this.firstName = firstName;
10 | this.age = age;
11 | }
12 |
13 | public int getAge() {
14 | return age;
15 | }
16 |
17 | public void setAge(int age) {
18 | this.age = age;
19 | }
20 |
21 | public String getFirstName() {
22 | return firstName;
23 | }
24 |
25 | public void setFirstName(String firstName) {
26 | this.firstName = firstName;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/easyb/bdd/Queue.java:
--------------------------------------------------------------------------------
1 | package org.easyb.bdd;
2 |
3 | import java.util.ArrayList;
4 |
5 | public class Queue