def test_feature_max_length_on_scenario_outline_keys(): "The max length of a feature considering when the table keys of the " "scenario oulines are longer than the remaining things" feature1 = Feature.from_string(FEATURE8) feature2 = Feature.from_string(FEATURE9) assert_equals(feature1.max_length, 68) assert_equals(feature2.max_length, 68)
def test_feature_max_length_on_scenario_outline_keys(): "The max length of a feature considering when the table keys of the " \ "scenario oulines are longer than the remaining things" feature1 = Feature.from_string(FEATURE8) feature2 = Feature.from_string(FEATURE9) assert_equals(feature1.max_length, 68) assert_equals(feature2.max_length, 68)
def test_feature_first_scenario_tags_extraction(): ("A feature object should be able to find the tags " "belonging to the first scenario") feature = Feature.from_string(FEATURE23) assert that(feature.scenarios[0].tags).deep_equals([ 'onetag', 'another', '$%^&even-weird_chars'])
def test_feature_first_scenario_tag_extraction(): ("A feature object should be able to find the single tag " "belonging to the first scenario") feature = Feature.from_string(FEATURE22) assert that(feature.scenarios[0].tags).deep_equals([ 'onetag'])
def test_scenarios_with_special_characters(): "Make sure that regex special characters in the scenario names are ignored" feature = Feature.from_string(FEATURE19) assert that(feature.scenarios[0].tags).deep_equals(['runme1']) assert that(feature.scenarios[1].tags).deep_equals(['runme2'])
def test_feature_first_scenario_tags_extraction(): ("A feature object should be able to find the tags " "belonging to the first scenario") feature = Feature.from_string(FEATURE23) assert that(feature.scenarios[0].tags).deep_equals( ['onetag', 'another', '$%^&even-weird_chars'])
def test_feature_ptbr_from_string(): 'Language: PT-BR -> Feature.from_string' ptbr = Language('pt-br') feature = Feature.from_string(FEATURE, language=ptbr) assert_equals( feature.name, u'Pesquisar alunos com matrícula vencida' ) assert_equals( feature.description, u"Como gerente financeiro\n" u"Eu quero pesquisar alunos com matrícula vencida\n" u"Para propor um financiamento" ) (scenario, ) = feature.scenarios assert_equals( scenario.name, 'Pesquisar por nome do curso' ) assert_equals( scenario.steps[-1].hashes, [ {'nome': u'João', u'valor devido': 'R$ 512,66'}, {'nome': u'Maria', u'valor devido': 'R$ 998,41'}, {'nome': u'Ana', u'valor devido': 'R$ 231,00'}, ] )
def test_feature_fr_from_string2(): 'Language: FR -> Feature.from_string, alternate name' lang = Language('fr') feature = Feature.from_string(OUTLINED_FEATURE2, language=lang) assert_equals( feature.name, u'Faire plusieur choses en même temps' ) assert_equals( feature.description, u"De façon à automatiser les tests\n" u"En tant que fainéant\n" u"J'utilise les plans de scénario" ) (scenario, ) = feature.scenarios assert_equals( scenario.name, 'Ajouter 2 nombres' ) assert_equals( scenario.outlines, [ {u'input_1':u'20',u'input_2':u'30',u'bouton':u'add',u'output':u'50'}, {u'input_1':u'2',u'input_2':u'5',u'bouton':u'add',u'output':u'7'}, {u'input_1':u'0',u'input_2':u'40',u'bouton':u'add',u'output':u'40'}, ] )
def test_after_each_step_is_executed_before_each_step(): "terrain.before.each_step and terrain.after.each_step decorators" world.step_states = [] @before.each_step def set_state_to_before(step): world.step_states.append('before') expected = 'Given I append "during" to states' if step.sentence != expected: raise TypeError('%r != %r' % (step.sentence, expected)) @step('append "during" to states') def append_during_to_step_states(step): world.step_states.append("during") @after.each_step def set_state_to_after(step): world.step_states.append('after') expected = 'Given I append "during" to states' if step.sentence != expected: raise TypeError('%r != %r' % (step.sentence, expected)) feature = Feature.from_string(FEATURE1) feature.run() assert_equals(world.step_states, ['before', 'during', 'after'])
def run(self): """ Find and load step definitions, and them find and load features under `base_path` specified on constructor """ started_at = datetime.now() self.loader.find_and_load_step_definitions() call_hook('before', 'all') results = [] if self.single_feature: features_files = [self.single_feature] else: features_files = self.loader.find_feature_files() if not features_files: self.output.print_no_features_found(self.loader.base_dir) return failed = False try: for filename in features_files: feature = Feature.from_file(filename) results.append(feature.run(self.scenarios)) except LettuceSyntaxError, e: sys.stderr.write(e.msg) failed = True
def run(self): """ Find and load step definitions, and them find and load features under `base_path` specified on constructor """ results = [] if self.single_feature: features_files = [self.single_feature] else: features_files = self.loader.find_feature_files() if self.random: random.shuffle(features_files) if not features_files: self.output.print_no_features_found(self.loader.base_dir) return # only load steps if we've located some features. # this prevents stupid bugs when loading django modules # that we don't even want to test. try: self.loader.find_and_load_step_definitions() except StepLoadingError as e: print("Error loading step definitions:\n", e) return call_hook('before', 'all') failed = False try: for filename in features_files: feature = Feature.from_file(filename) results.append( feature.run(self.scenarios, tags=self.tags, random=self.random, failfast=self.failfast)) except exceptions.LettuceSyntaxError as e: sys.stderr.write(e.msg) failed = True except: if not self.failfast: e = sys.exc_info()[1] print("Died with %s" % str(e)) traceback.print_exc() else: print("Lettuce aborted running any more tests " "because was called with the `--failfast` option") failed = True finally: total = TotalResult(results) total.output_format() call_hook('after', 'all', total) if failed: raise SystemExit(2) return total
def test_description_on_big_sentenced_steps(): "Can parse the description on long sentenced steps" feature = Feature.from_string(FEATURE4) assert_equals( feature.description, "As a clever guy\n" "I want to describe this Feature\n" "So that I can take care of my Scenario", )
def run(self): """ Find and load step definitions, and them find and load features under `base_path` specified on constructor """ self.loader.find_and_load_step_definitions() for callback in CALLBACK_REGISTRY['all']['before']: callback() results = [] if self.single_feature: features_files = [self.single_feature] else: features_files = self.loader.find_feature_files() if not features_files: self.output.print_no_features_found(self.loader.base_dir) return try: for filename in features_files: feature = Feature.from_file(filename) results.append(feature.run()) except LettuceSyntaxError, e: sys.stderr.write(e.msg) raise SystemExit(2)
def test_feature_loaded_from_file_sets_step_line_and_step_filenames(): "Feature.from_file sets StepDescription into Scenario objects, " \ "giving line number and filename as well" feature_file = cjoin('1st_feature_dir', 'one_more.feature') feature = Feature.from_file(feature_file) (scenario, ) = feature.scenarios step1, step2, step3, step4 = scenario.steps for step in scenario.steps: assert_equals(step.described_at.file, fs.relpath(feature_file)) assert_equals(step1.sentence, "* I have entered 10 into the calculator") assert_equals(step1.described_at.line, 7) assert_equals(step2.sentence, "* I have entered 4 into the calculator") assert_equals(step2.described_at.line, 8) assert_equals(step3.sentence, "* I press multiply") assert_equals(step3.described_at.line, 9) assert_equals(step4.sentence, "* the result should be 40 on the screen") assert_equals(step4.described_at.line, 10)
def test_feature_has_scenarios(): "A feature object should have a list of scenarios" feature = Feature.from_string(FEATURE1) assert_equals(type(feature.scenarios), list) assert_equals(len(feature.scenarios), 3, "It should have 3 scenarios") expected_scenario_names = [ "Renting a featured movie", "Renting a non-featured movie", "Renting two movies allows client to take one more without charge", ] for scenario, expected_name in zip(feature.scenarios, expected_scenario_names): assert_equals(type(scenario), Scenario) assert_equals(scenario.name, expected_name) assert_equals(feature.scenarios[1].steps[0].keys, ('Name', 'Rating', 'New', 'Available')) assert_equals( feature.scenarios[1].steps[0].hashes, [ {'Name': 'A night at the museum 2', 'Rating': '3 stars', 'New': 'yes', 'Available': '9'}, {'Name': 'Matrix Revolutions', 'Rating': '4 stars', 'New': 'no', 'Available': '6'}, ] )
def test_outline_hooks(): "terrain.before.each_outline and terrain.after.each_outline decorators" world.scenario_names = set() world.hooks = [] @before.each_scenario def before_scenario(scenario): world.hooks.append("before scenario {0}".format(scenario.name)) @after.each_scenario def after_scenario(scenario): world.hooks.append("after scenario {0}".format(scenario.name)) @before.each_outline def before_outline(scenario, outline): world.scenario_names.add(scenario.name) world.hooks.append("before {0}".format(outline["outline"])) @after.each_outline def after_outline(scenario, outline): world.scenario_names.add(scenario.name) world.hooks.append("after {0}".format(outline["outline"])) feature = Feature.from_string(OUTLINE_FEATURE) feature.run() assert_equals(world.hooks, ['before scenario Outlines', 'before first_outline', 'after first_outline', 'before second_outline', 'after second_outline', 'after scenario Outlines'])
def test_feature_ptbr_from_string(): 'Language: RU -> Feature.from_string' ru = Language('ru') feature = Feature.from_string(FEATURE, language=ru) assert_equals( feature.name, u'Деление чисел' ) assert_equals( feature.description, u"Поскольку деление сложный процесс и люди часто допускают ошибки\n" u"Нужно дать им возможность делить на калькуляторе" ) (scenario, ) = feature.scenarios assert_equals( scenario.name, u'Целочисленное деление' ) assert_equals( scenario.steps[-1].hashes, [ {u'делимое': '100', u'делитель': '2', u'частное': '50'}, {u'делимое': '28', u'делитель': '7', u'частное': '4'}, {u'делимое': '0', u'делитель': '5', u'частное': '0'}, ] )
def test_feature_ptbr_from_string(): 'Language: RU -> Feature.from_string' ru = Language('ru') feature = Feature.from_string(FEATURE, language=ru) assert_equals(feature.name, 'Деление чисел') assert_equals( feature.description, "Поскольку деление сложный процесс и люди часто допускают ошибки\n" "Нужно дать им возможность делить на калькуляторе") (scenario, ) = feature.scenarios assert_equals(scenario.name, 'Целочисленное деление') assert_equals(scenario.steps[-1].hashes, [ { 'делимое': '100', 'делитель': '2', 'частное': '50' }, { 'делимое': '28', 'делитель': '7', 'частное': '4' }, { 'делимое': '0', 'делитель': '5', 'частное': '0' }, ])
def test_description_on_big_sentenced_steps(): "Can parse the description on long sentenced steps" feature = Feature.from_string(FEATURE4) assert_equals( feature.description, "As a clever guy\n" "I want to describe this Feature\n" "So that I can take care of my Scenario")
def run(self): """ Find and load step definitions, and them find and load features under `base_path` specified on constructor """ started_at = datetime.now() self.loader.find_and_load_step_definitions() call_hook('before', 'all') results = [] if self.single_feature: features_files = [self.single_feature] else: features_files = self.loader.find_feature_files() if not features_files: self.output.print_no_features_found(self.loader.base_dir) return failed = False try: for filename in features_files: feature = Feature.from_file(filename) results.append(feature.run(self.scenarios)) except exceptions.LettuceSyntaxError, e: sys.stderr.write(e.msg) failed = True
def test_scenario_outlines_within_feature(): "Solving scenario outlines within a feature" feature = Feature.from_string(OUTLINED_FEATURE) scenario = feature.scenarios[0] assert_equals(len(scenario.solved_steps), 12) expected_sentences = [ 'Given I have entered 20 into the calculator', 'And I have entered 30 into the calculator', 'When I press add', 'Then the result should be 50 on the screen', 'Given I have entered 2 into the calculator', 'And I have entered 5 into the calculator', 'When I press add', 'Then the result should be 7 on the screen', 'Given I have entered 0 into the calculator', 'And I have entered 40 into the calculator', 'When I press add', 'Then the result should be 40 on the screen', ] for step, expected_sentence in zip(scenario.solved_steps, expected_sentences): assert_equals(type(step), Step) assert_equals(step.sentence, expected_sentence)
def test_scenarios_parsed_by_feature_has_feature(): "Scenarios parsed by features has feature" feature = Feature.from_string(FEATURE2) for scenario in feature.scenarios: assert_equals(scenario.feature, feature)
def test_outline_hooks(): "terrain.before.each_outline and terrain.after.each_outline decorators" world.scenario_names = set() world.hooks = [] @before.each_scenario def before_scenario(scenario): world.hooks.append("before scenario {0}".format(scenario.name)) @after.each_scenario def after_scenario(scenario): world.hooks.append("after scenario {0}".format(scenario.name)) @before.each_outline def before_outline(scenario, outline): world.scenario_names.add(scenario.name) world.hooks.append("before {0}".format(outline["outline"])) @after.each_outline def after_outline(scenario, outline): world.scenario_names.add(scenario.name) world.hooks.append("after {0}".format(outline["outline"])) feature = Feature.from_string(OUTLINE_FEATURE) feature.run() assert_equals(world.hooks, [ 'before scenario Outlines', 'before first_outline', 'after first_outline', 'before second_outline', 'after second_outline', 'after scenario Outlines' ])
def test_feature_has_scenarios(): "A feature object should have a list of scenarios" feature = Feature.from_string(FEATURE1) assert_equals(type(feature.scenarios), list) assert_equals(len(feature.scenarios), 3, "It should have 3 scenarios") expected_scenario_names = [ "Renting a featured movie", "Renting a non-featured movie", "Renting two movies allows client to take one more without charge", ] for scenario, expected_name in zip(feature.scenarios, expected_scenario_names): assert_equals(type(scenario), Scenario) assert_equals(scenario.name, expected_name) assert_equals(feature.scenarios[1].steps[0].keys, ('Name', 'Rating', 'New', 'Available')) assert_equals(feature.scenarios[1].steps[0].hashes, [ { 'Name': 'A night at the museum 2', 'Rating': '3 stars', 'New': 'yes', 'Available': '9' }, { 'Name': 'Matrix Revolutions', 'Rating': '4 stars', 'New': 'no', 'Available': '6' }, ])
def test_background_parsing_without_mmf(): feature = Feature.from_string(FEATURE17) expect(feature.description).to.be.empty expect(feature).to.have.property('background').being.a(Background) expect(feature.background).to.have.property('steps') expect(feature.background.steps).to.have.length_of(2) step1, step2 = feature.background.steps step1.sentence.should.equal( 'Given I have the following movies in my database:') step1.hashes.should.equal(HashList(step1, [ { u'Available': u'6', u'Rating': u'4 stars', u'Name': u'Matrix Revolutions', u'New': u'no', }, { u'Available': u'11', u'Rating': u'5 stars', u'Name': u'Iron Man 2', u'New': u'yes', }, ])) step2.sentence.should.equal( 'And the following clients:') step2.hashes.should.equal(HashList(step2, [ {u'Name': u'John Doe'}, {u'Name': u'Foo Bar'}, ]))
def test_feature_ptbr_from_string(): 'Language: PT-BR -> Feature.from_string' ptbr = Language('pt-br') feature = Feature.from_string(FEATURE, language=ptbr) assert_equals(feature.name, u'Pesquisar alunos com matrícula vencida') assert_equals( feature.description, u"Como gerente financeiro\n" u"Eu quero pesquisar alunos com matrícula vencida\n" u"Para propor um financiamento") (scenario, ) = feature.scenarios assert_equals(scenario.name, 'Pesquisar por nome do curso') assert_equals(scenario.steps[-1].hashes, [ { 'nome': u'João', u'valor devido': 'R$ 512,66' }, { 'nome': u'Maria', u'valor devido': 'R$ 998,41' }, { 'nome': u'Ana', u'valor devido': 'R$ 231,00' }, ])
def test_feature_has_scenarios(): "A feature object should have a list of scenarios" feature = Feature.from_string(FEATURE1) assert_equals(type(feature.scenarios), list) assert_equals(len(feature.scenarios), 3, "It should have 3 scenarios") expected_scenario_names = [ "Renting a featured movie", "Renting a non-featured movie", "Renting two movies allows client to take one more without charge", ] for scenario, expected_name in zip(feature.scenarios, expected_scenario_names): assert_equals(type(scenario), Scenario) assert_equals(scenario.name, expected_name) assert_equals(feature.scenarios[1].steps[0].keys, ("Name", "Rating", "New", "Available")) assert_equals( feature.scenarios[1].steps[0].hashes, [ {"Name": "A night at the museum 2", "Rating": "3 stars", "New": "yes", "Available": "9"}, {"Name": "Matrix Revolutions", "Rating": "4 stars", "New": "no", "Available": "6"}, ], )
def test_feature_has_scenarios(): "A feature object should have a list of scenarios" feature = Feature.from_string(FEATURE1) expect(feature.scenarios).to.be.a(list) expect(feature.scenarios).to.have.length_of(3) expected_scenario_names = [ "Renting a featured movie", "Renting a non-featured movie", "Renting two movies allows client to take one more without charge", ] for scenario, expected_name in zip(feature.scenarios, expected_scenario_names): expect(scenario).to.be.a(Scenario) expect(scenario.name).to.equal(expected_name) expect(feature.scenarios[1].steps[0].keys).to.equal( ('Name', 'Rating', 'New', 'Available')) expect(list(feature.scenarios[1].steps[0].hashes)).to.equal([ { 'Name': 'A night at the museum 2', 'Rating': '3 stars', 'New': 'yes', 'Available': '9', }, { 'Name': 'Matrix Revolutions', 'Rating': '4 stars', 'New': 'no', 'Available': '6', }, ])
def parse_scenario(string, language=None): feature = u""" Функция: parse_scenario """ feature += string feature = Feature.from_string(feature, language=language) return feature.scenarios[0]
def test_single_scenario_single_scenario(): "Features should have at least the first scenario parsed with tags" feature = Feature.from_string(FEATURE11) first_scenario = feature.scenarios[0] assert that(first_scenario.tags).deep_equals([ 'many', 'other', 'basic', 'tags', 'here', ':)'])
def test_scenario_has_name(): "It should extract the name string from the scenario" feature = Feature.from_string(FEATURE1) assert isinstance(feature, Feature) expect(feature.name).to.equal("Rent movies")
def test_description_on_long_named_feature(): "Can parse the description on long named features" feature = Feature.from_string(FEATURE3) assert_equals( feature.description, "In order to describe my features\n" "I want to add description on them", )
def test_single_scenario_single_scenario(): "Features should have at least the first scenario parsed with tags" feature = Feature.from_string(FEATURE11) first_scenario = feature.scenarios[0] assert that(first_scenario.tags).deep_equals( ['many', 'other', 'basic', 'tags', 'here', ':)'])
def test_skipped_steps_can_be_retrieved_as_steps(): "Skipped steps can be retrieved as steps" f = Feature.from_string(FEATURE1) feature_result = f.run() scenario_result = feature_result.scenario_results[0] for step in scenario_result.steps_skipped: assert_equals(type(step), Step)
def test_scenario_representation_without_colors(): "Scenario represented without colors" feature_file = ojoin('runner_features', 'first.feature') feature = Feature.from_file(feature_file) assert_equals( feature.scenarios[0].represented(), " Scenario: Do nothing # tests/functional/output_features/runner_features/first.feature:6\n" )
def test_feature_and_scenario_tags_extraction(): "Feature tags should be applied to all its scenarios" feature = Feature.from_string(FEATURE24) assert that(feature.scenarios[0].tags).deep_equals([ 'feature-tag']) assert that(feature.scenarios[1].tags).deep_equals([ 'scenario-tag', 'feature-tag'])
def test_ignore_case_on_step_definitions(): "By default lettuce ignore case on step definitions" f = Feature.from_string(FEATURE3) feature_result = f.run() scenario_result = feature_result.scenario_results[0] assert_equals(len(scenario_result.steps_passed), 3) assert_equals(scenario_result.total_steps, 3) assert all([s.has_definition for s in scenario_result.scenario.steps])
def test_feature_has_background(): """Ensure that background section is parsed as expected""" feature = Feature.from_string(FEATURE2) assert feature.background is not None assert feature.background.steps assert_equals(len(feature.background.steps), 1) assert_equals(len(feature.scenarios), 1) assert_equals(len(feature.scenarios[0].steps), 4)
def test_background(): "It should parse the background section" feature = Feature.from_string(FEATURE11) assert_true(feature.background is not None) assert_equals(len(feature.background.steps), 2) assert_equals(feature.background.steps[0].sentence, "Given I'm working at Video Library") assert_equals(feature.background.steps[1].sentence, "And there is a sale today")
def test_scenarios_with_special_characters(): "Make sure that regex special characters in the scenario names are ignored" feature = Feature.from_string(FEATURE19) assert that(feature.scenarios[0].tags).deep_equals([ 'runme1']) assert that(feature.scenarios[1].tags).deep_equals([ 'runme2'])
def test_scenario_outline_representation_without_colors(): "Scenario Outline represented without colors" feature_file = ojoin('..', 'simple_features', '1st_feature_dir', 'some.feature') feature = Feature.from_file(feature_file) assert_equals( feature.scenarios[0].represented(), " Scenario Outline: Add two numbers # tests/functional/simple_features/1st_feature_dir/some.feature:10\n" )
def test_full_featured_feature(): "Solving scenarios within a full-featured feature" feature = Feature.from_string(OUTLINED_FEATURE_WITH_MANY) scenario1, scenario2, scenario3, scenario4 = feature.scenarios assert_equals(scenario1.name, 'Do something') assert_equals(scenario2.name, 'Do something else') assert_equals(scenario3.name, 'Worked!') assert_equals(scenario4.name, 'Add two numbers wisely') assert_equals(len(scenario1.solved_steps), 2) expected_sentences = [ 'Given I have entered ok into the fail', 'Given I have entered fail into the ok', ] for step, expected_sentence in zip(scenario1.solved_steps, expected_sentences): assert_equals(step.sentence, expected_sentence) expected_evaluated = ( ( {'button': 'add', 'input_1': '20', 'input_2': '30', 'output': '50'}, [ 'Given I have entered 20 into the calculator', 'And I have entered 30 into the calculator', 'When I press add', 'Then the result should be 50 on the screen', ] ), ( {'button': 'add', 'input_1': '2', 'input_2': '5', 'output': '7'}, [ 'Given I have entered 2 into the calculator', 'And I have entered 5 into the calculator', 'When I press add', 'Then the result should be 7 on the screen', ] ), ( {'button': 'add', 'input_1': '0', 'input_2': '40', 'output': '40'}, [ 'Given I have entered 0 into the calculator', 'And I have entered 40 into the calculator', 'When I press add', 'Then the result should be 40 on the screen', ], ), ( {'button': 'add', 'input_1': '5', 'input_2': '7', 'output': '12'}, [ 'Given I have entered 5 into the calculator', 'And I have entered 7 into the calculator', 'When I press add', 'Then the result should be 12 on the screen', ], ) ) for ((got_examples, got_steps), (expected_examples, expected_steps)) in zip(scenario4.evaluated, expected_evaluated): sentences_of = lambda x: x.sentence assert_equals(got_examples, expected_examples) assert_equals(list(map(sentences_of, got_steps)), expected_steps)
def test_feature_hooks_not_invoked_if_no_scenarios_run(): feature = Feature.from_string(FEATURE3) world.feature_steps = [] feature.run(tags=['tag1']) assert_equals(world.feature_steps, ['before', 'during', 'after']) world.feature_steps = [] feature.run(tags=['tag3']) assert_equals(world.feature_steps, [])
def test_scenario_post_email(): ("Having a scenario which the body has an email address; " "Then the following scenario should have no " "tags related to the email") feature = Feature.from_string(FEATURE21) scenario1, scenario2 = feature.scenarios scenario1.tags.should.be.empty scenario2.tags.should.equal(['tag'])
def test_features(self): import lettuce_webdriver.webdriver import lettuce_webdriver.css_selector_steps for feature_string in FEATURES: f = Feature.from_string(feature_string) feature_result = f.run(failfast=True) scenario_result = feature_result.scenario_results[0] self.assertFalse(scenario_result.steps_failed) self.assertFalse(scenario_result.steps_skipped) self.assertFalse(scenario_result.steps_undefined)
def test_count_raised_exceptions_as_failing_steps(): "When a step definition raises an exception, it is marked as a failed step. " try: f = Feature.from_string(FEATURE8) feature_result = f.run() scenario_result = feature_result.scenario_results[0] assert_equals(len(scenario_result.steps_failed), 1) finally: registry.clear()
def test_doesnt_ignore_case(): "Lettuce can, optionally consider case on step definitions" f = Feature.from_string(FEATURE3) feature_result = f.run(ignore_case=False) scenario_result = feature_result.scenario_results[0] assert_equals(len(scenario_result.steps_passed), 1) assert_equals(len(scenario_result.steps_undefined), 2) assert_equals(scenario_result.total_steps, 3) assert not all([s.has_definition for s in scenario_result.scenario.steps])
def test_steps_that_match_groups_and_named_groups_takes_just_named_as_params(): "Steps that match groups and named groups takes just the named as parameters" @step(r'(he|she) gets a (?P<what>\w+)') def given_action_named(step, what): assert_equals(what, 'caipirinha') f = Feature.from_string(FEATURE6) feature_result = f.run() scenario_result = feature_result.scenario_results[0] assert_equals(len(scenario_result.steps_passed), 1) assert_equals(scenario_result.total_steps, 1)
def test_feature_loaded_from_file_has_feature_line_and_feature_filename(): "Feature.from_file sets FeatureDescription into Feature objects, " \ "giving line number and filename as well" feature_file = cjoin('1st_feature_dir', 'more_features_here', 'another.feature') feature = Feature.from_file(feature_file) assert_equals(feature.described_at.file, fs.relpath(feature_file)) assert_equals(feature.described_at.line, 2) assert_equals(feature.name, 'Division') assert_equals(feature.described_at.description_at, (3, 4))
def test_scenarios_with_extra_whitespace(): "Make sure that extra leading whitespace is ignored" feature = Feature.from_string(FEATURE14) assert_equals(type(feature.scenarios), list) assert_equals(len(feature.scenarios), 1, "It should have 1 scenario") assert_equals(feature.name, "Extra whitespace feature") scenario = feature.scenarios[0] assert_equals(type(scenario), Scenario) assert_equals(scenario.name, "Extra whitespace scenario")