dox Executable Documentation

Parse steps

A step is meant in the SbE sense being a sentence starting with given, when or then. In code, steps are methods that use a special syntax for in-lining arguments.

Step without arguments

When I parse the method body '$this->givenSomething();'
Then the scenario should contain '{ "code": "$this->givenSomething()", "step": [ "Given something" ] }'

Step with arguments

When I parse the method body '$this->givenSomething(2);'
Then the scenario should contain '{ "code": "$this->givenSomething(2)", "step": [ "Given something", {"value":"2"} ] }'

Method in composed object

When I parse the method body '$this->property->givenSomething();'
Then the scenario should contain '{ "code": "$this->property->givenSomething()", "step": [ "Given something" ] }'

Inline arguments

Underscores are used as placeholders for arguments (trailing underscores can be omitted)

When I parse the method body ' $this->given_Has_Cows("Bart", 2); $this->given_Is("Bart", 10);'
Then the scenario should contain '[ "Given", {"value": "\'Bart\'"}, "has", {"value": "2"}, "cows" ]'
Then the scenario should contain '[ "Given", {"value": "\'Bart\'"}, "is", {"value": "10"} ]'

Two steps

When I parse the method body ' $this->givenSomething(); $this->givenSomethingElse();'
Then the scenario should contain '[ { "code": "$this->givenSomething()", "step": ["Given something"] }, { "code": "$this->givenSomethingElse()", "step": ["Given something else"] } ]'

Different groups

When I parse the method body ' $this->givenSomething(); $this->givenSomethingElse(); $this->whenSomethingHappens(); $this->thenItShouldBeOk(); $this->whenThis();'
Then the scenario should contain '[ [ { "code": "$this->givenSomething()", "step": ["Given something"] }, { "code": "$this->givenSomethingElse()", "step": ["Given something else"] } ], [ { "code": "$this->whenSomethingHappens()", "step": ["When something happens"] } ], [ { "code": "$this->thenItShouldBeOk()", "step": ["Then it should be ok"] } ], [ { "code": "$this->whenThis()", "step": ["When this"] } ] ]'

Camel case exceptions

Some words should not be lower-case

When I parse the method body '$this->whenIDoSomething();'
Then the scenario should contain '"When I do something"'

Non scalar arguments

When I parse the method body '$this->given(array(), null);'
Then the scenario should contain '[ "Given", {"value": "array()"}, {"value": "null"} ]'

Indented string

For some reason, the parser adds a token when printing indented strings

When I parse the method body ' $this->given(" Something indented ");'
Then the scenario should contain '[ "Given", {"value": "\'\\nSomething\\nindented\\n\'"} ]'