Menu

Add sub scenarios to parent scenario from code

Roy
2013-01-07
2013-01-08
  • Roy

    Roy - 2013-01-07

    Hi,

    i'm looking for a way to add scenarios as "Sub Scenarios" to a parent scenario from code.
    it should read some folder which is populated with new scenario files and add them to an existing scenario file as sub scenarios + marking those sub scenarios as Tests.

    is there a way to do it using JSystem API or something ?

    thanks,
    Roy.

     
  • Itai Agmon

    Itai Agmon - 2013-01-08

    Hi. I've just made such an example for another user.

        @Test
        @TestProperties(name = "Add existing scenarios ${scenario1} and ${scenario2} to a new scenario ${newScenarioName}", paramsInclude = {
                "scenario1", "scenario2", "newScenarioName" })
        public void addExistingScenariosToNewOne() throws Exception {
            final File scenarioFolder = new File(JSystemProperties.getInstance().getPreference(
                    FrameworkOptions.TESTS_CLASS_FOLDER));
            JSystemProperties.getInstance().setJsystemRunner(true);
    
            Scenario root = new Scenario(scenarioFolder, "scenarios/" + newScenarioName);
            Scenario s1 = ScenariosManager.getInstance().getScenario("scenarios/" + scenario1);
            Scenario s2 = ScenariosManager.getInstance().getScenario("scenarios/" + scenario2);
            root.addTest(s1);
            root.addTest(s2);
            root.save();
    
            Scenario subScenario = (Scenario) root.getTestFromRoot(0);
    
            subScenario.setScenarioAsTest(true);
            subScenario.hideInHTML(true);
            subScenario.markAsKnownIssue(true);
            subScenario.setDocumentation("My documentation");
            root.save();
            JSystemProperties.getInstance().setJsystemRunner(false);
    
            report.report("Refresh the runner to see the new scenario");
    
        }
    

    Just notice that this example was tested with JSystem 6.00.0 rc-3 Snapshot which is available for download from: http://80.74.108.9/content/repositories/snapshots/org/jsystemtest/jsystem-runner/6.0.00-rc-3-SNAPSHOT/

     

Log in to post a comment.