Permalink
Browse files

passing scenario through argument

  • Loading branch information...
1 parent 11423a0 commit 8421542a69e11cb1f0f0386728f6c474882c5da2 @jcfigueiredo jcfigueiredo committed Apr 7, 2009
Showing with 19 additions and 3 deletions.
  1. +2 −0 pyccuracy/pyccuracy_console.py
  2. +14 −3 pyccuracy/pyccuracy_core.py
  3. +3 −0 pyccuracy/story_runner.py
@@ -45,6 +45,7 @@ def main():
parser.add_option("-P", "--pagesdir", dest="pages_dir", default=None, help="Pages directory. Defines where the Pyccuracy custom pages are. If you don't change this parameter Pyccuracy will use the tests directory [default: %default].")
parser.add_option("-u", "--url", dest="url", default=None, help="Base URL. Defines a base url against which the tests will get executed. For more details check the documentation [default: %default].")
parser.add_option("-b", "--browser", dest="browser_to_run", default="firefox", help="Browser to run. Browser driver will use it to run tests [default: %default].")
+ parser.add_option("-s", "--scenario", dest="scenario_to_run", default=None, help="Scenario to run. Browser driver will run this scenario only [default: %default].")
#browser driver
parser.add_option("-e", "--browserdriver", dest="browser_driver", default="selenium", help="Browser Driver to be used on tests. [default: %default].")
@@ -73,6 +74,7 @@ def main():
report_file_dir=options.report_dir,
report_file_name=options.report_file_name,
browser_to_run=options.browser_to_run,
+ scenario_to_run=options.scenario_to_run,
browser_driver=options.browser_driver,
should_throw=options.should_throw)
@@ -42,6 +42,7 @@ def configure_context(self,
should_throw,
write_report,
browser_to_run,
+ scenario_to_run,
browser_driver,
context):
IoC.reset()
@@ -61,6 +62,9 @@ def configure_context(self,
if not report_file_dir:
report_file_dir = tests_dir
+ if not scenario_to_run:
+ scenario_to_run = unicode(scenario_to_run)
+
lang = self.load_language(languages_dir, default_culture)
self.configure_ioc(languages_dir=languages_dir,
@@ -73,6 +77,7 @@ def configure_context(self,
custom_actions_dir=custom_actions_dir,
lang=lang,
browser_to_run=browser_to_run,
+ scenario_to_run=scenario_to_run,
browser_driver=browser_driver,
write_report=write_report,
report_file_dir=report_file_dir,
@@ -100,6 +105,7 @@ def configure_ioc(self,
base_url,
lang,
browser_to_run,
+ scenario_to_run,
browser_driver,
write_report):
@@ -126,7 +132,8 @@ def configure_ioc(self,
config.register("story_runner", StoryRunner)
- config.register("browser_to_run", "*%s" % browser_to_run)
+ config.register("browser_to_run", "*%s" % browser_to_run)
+ config.register("scenario_to_run", scenario_to_run)
config.register("scripts_path", abspath(dirname(__file__)))
config.register("base_url", base_url)
@@ -148,6 +155,7 @@ def run_tests(self,
report_file_dir=None,
report_file_name="report.html",
browser_to_run="chrome",
+ scenario_to_run=None,
browser_driver="selenium"):
result = self.configure_context(
@@ -164,6 +172,7 @@ def run_tests(self,
should_throw=should_throw,
write_report=write_report,
browser_to_run=browser_to_run,
+ scenario_to_run=scenario_to_run,
browser_driver=browser_driver,
context=context)
if result:
@@ -230,7 +239,8 @@ def __init__(self,
base_url,
report_file_dir,
report_file_name,
- write_report):
+ write_report,
+ scenario_to_run):
self.browser_driver = browser_driver
self.language = language
self.test_fixture_parser = test_fixture_parser
@@ -243,6 +253,7 @@ def __init__(self,
self.base_url = base_url
self.all_custom_actions = all_custom_actions
self.all_actions = all_actions
- self.report_file_dir = report_file_dir
+ self.report_file_dir = report_file_dir
self.report_file_name = report_file_name
self.write_report = write_report
+ self.scenario_to_run = scenario_to_run
@@ -51,6 +51,9 @@ def run_stories(self, context):
def __run_scenarios(self, current_story, context):
for current_scenario in current_story.scenarios:
+ if not context.scenario_to_run and current_scenario.title <> context.scenario_to_run:
+ continue
+
self.raise_pre_scenario(context, current_story, current_scenario)
current_scenario.start_run()
for current_action in (current_scenario.givens + current_scenario.whens + current_scenario.thens):

0 comments on commit 8421542

Please sign in to comment.