def teste_parse_scenario_with_description(): parser = Parser( [ (1, gherkin.TOKEN_LABEL, "Scenario"), (1, gherkin.TOKEN_TEXT, "Scenario title"), (1, gherkin.TOKEN_NEWLINE, "\n"), (2, gherkin.TOKEN_TEXT, "Scenario description"), (2, gherkin.TOKEN_TEXT, "More description"), (2, gherkin.TOKEN_NEWLINE, "\n"), (3, gherkin.TOKEN_TEXT, "Given first step"), ] ) feature = parser.parse_scenarios() feature.should.equal( [ Ast.Scenario( line=1, title=Ast.Text(line=1, text="Scenario title"), description=Ast.Text(line=2, text="Scenario description More description"), steps=[Ast.Step(line=3, title=Ast.Text(line=3, text="Given first step"))], ) ] )
def teste_parse_scenario_with_description(): parser = Parser([ (1, gherkin.TOKEN_LABEL, 'Scenario'), (1, gherkin.TOKEN_TEXT, 'Scenario title'), (1, gherkin.TOKEN_NEWLINE, '\n'), (2, gherkin.TOKEN_TEXT, 'Scenario description'), (2, gherkin.TOKEN_TEXT, 'More description'), (2, gherkin.TOKEN_NEWLINE, '\n'), (3, gherkin.TOKEN_TEXT, 'Given first step'), ]) feature = parser.parse_scenarios() feature.should.equal([ Ast.Scenario( line=1, title=Ast.Text(line=1, text='Scenario title'), description=Ast.Text(line=2, text='Scenario description More description'), steps=[ Ast.Step(line=3, title=Ast.Text(line=3, text='Given first step')) ], ) ])
def test_parse_scenario_outline_with_examples(): "" # Given a parser loaded with the following gherkin document: # # Scenario Outline: Plant a tree # Given the <name> of a garden # When I plant a tree # And wait for <num_days> days # Then I see it growing # Examples: # | name | num_days | # | Secret | 2 | # | Octopus | 5 | parser = Parser( [ (1, gherkin.TOKEN_LABEL, "Scenario Outline"), (1, gherkin.TOKEN_TEXT, "Plant a tree"), (1, gherkin.TOKEN_NEWLINE, "\n"), (2, gherkin.TOKEN_TEXT, "Given the <name> of a garden"), (2, gherkin.TOKEN_NEWLINE, "\n"), (3, gherkin.TOKEN_TEXT, "When I plant a tree"), (3, gherkin.TOKEN_NEWLINE, "\n"), (4, gherkin.TOKEN_TEXT, "And wait for <num_days> days"), (4, gherkin.TOKEN_NEWLINE, "\n"), (5, gherkin.TOKEN_TEXT, "Then I see it growing"), (5, gherkin.TOKEN_NEWLINE, "\n"), (6, gherkin.TOKEN_LABEL, "Examples"), (6, gherkin.TOKEN_NEWLINE, "\n"), (7, gherkin.TOKEN_TABLE_COLUMN, "name"), (7, gherkin.TOKEN_TABLE_COLUMN, "num_days"), (7, gherkin.TOKEN_NEWLINE, "\n"), (8, gherkin.TOKEN_TABLE_COLUMN, "Secret"), (8, gherkin.TOKEN_TABLE_COLUMN, "2"), (8, gherkin.TOKEN_NEWLINE, "\n"), (9, gherkin.TOKEN_TABLE_COLUMN, "Octopus"), (9, gherkin.TOKEN_TABLE_COLUMN, "5"), (9, gherkin.TOKEN_NEWLINE, "\n"), (10, gherkin.TOKEN_EOF, ""), ] ) scenarios = parser.parse_scenarios() scenarios.should.equal( [ Ast.ScenarioOutline( line=1, title=Ast.Text(line=1, text="Plant a tree"), steps=[ Ast.Step(line=2, title=Ast.Text(line=2, text="Given the <name> of a garden")), Ast.Step(line=3, title=Ast.Text(line=3, text="When I plant a tree")), Ast.Step(line=4, title=Ast.Text(line=4, text="And wait for <num_days> days")), Ast.Step(line=5, title=Ast.Text(line=5, text="Then I see it growing")), ], examples=Ast.Examples( line=6, table=Ast.Table(line=7, fields=[["name", "num_days"], ["Secret", "2"], ["Octopus", "5"]]) ), ) ] )
def test_parse_scenario_outline_with_examples(): "" # Given a parser loaded with the following gherkin document: # # Scenario Outline: Plant a tree # Given the <name> of a garden # When I plant a tree # And wait for <num_days> days # Then I see it growing # Examples: # | name | num_days | # | Secret | 2 | # | Octopus | 5 | parser = Parser([(1, gherkin.TOKEN_LABEL, 'Scenario Outline'), (1, gherkin.TOKEN_TEXT, 'Plant a tree'), (1, gherkin.TOKEN_NEWLINE, '\n'), (2, gherkin.TOKEN_TEXT, 'Given the <name> of a garden'), (2, gherkin.TOKEN_NEWLINE, '\n'), (3, gherkin.TOKEN_TEXT, 'When I plant a tree'), (3, gherkin.TOKEN_NEWLINE, '\n'), (4, gherkin.TOKEN_TEXT, 'And wait for <num_days> days'), (4, gherkin.TOKEN_NEWLINE, '\n'), (5, gherkin.TOKEN_TEXT, 'Then I see it growing'), (5, gherkin.TOKEN_NEWLINE, '\n'), (6, gherkin.TOKEN_LABEL, 'Examples'), (6, gherkin.TOKEN_NEWLINE, '\n'), (7, gherkin.TOKEN_TABLE_COLUMN, 'name'), (7, gherkin.TOKEN_TABLE_COLUMN, 'num_days'), (7, gherkin.TOKEN_NEWLINE, '\n'), (8, gherkin.TOKEN_TABLE_COLUMN, 'Secret'), (8, gherkin.TOKEN_TABLE_COLUMN, '2'), (8, gherkin.TOKEN_NEWLINE, '\n'), (9, gherkin.TOKEN_TABLE_COLUMN, 'Octopus'), (9, gherkin.TOKEN_TABLE_COLUMN, '5'), (9, gherkin.TOKEN_NEWLINE, '\n'), (10, gherkin.TOKEN_EOF, '')]) scenarios = parser.parse_scenarios() scenarios.should.equal([ Ast.ScenarioOutline( line=1, title=Ast.Text(line=1, text='Plant a tree'), steps=[ Ast.Step(line=2, title=Ast.Text(line=2, text='Given the <name> of a garden')), Ast.Step(line=3, title=Ast.Text(line=3, text='When I plant a tree')), Ast.Step(line=4, title=Ast.Text(line=4, text='And wait for <num_days> days')), Ast.Step(line=5, title=Ast.Text(line=5, text='Then I see it growing')) ], examples=Ast.Examples(line=6, table=Ast.Table(line=7, fields=[ ['name', 'num_days'], ['Secret', '2'], ['Octopus', '5'], ]))) ])