| ILOG JRules User Guide > Testing Rules with Rule Scenario Manager > Tasks > Executing Scenarios, Scenario Suites, Simulations, and RSM Archives > Ant Commands for Scenario Execution |
Ant Commands for Scenario Execution |
PREVIOUS NEXT |
If you want to run your scenario, scenario suite, or simulation in a command line, you have to write the corresponding JUnit tests (http://junit.sourceforge.net) and run it with a JUnit runner (textUI, SwingUI ...). This is done with the suite() method, which creates a suite containing all your test methods:
package mypackage;
// jrules-rsm-core.jar
import ilog.rules.ras.binding.xml.impl.IlrXMLRSMBindingObjectImpl;
import ilog.rules.ras.core.scenario.impl.IlrScenarioSuiteImpl;
import ilog.rules.ras.core.scenario.impl.wrapper.IlrScenarioSuiteWrapperImpl;
// junit.jar
import junit.framework.Test;
public class MyScenarioJUnit {
public static Test suite() throws Exception {
// Use the RSM Binding class to read the set of files
IlrXMLRSMBindingObjectImpl binding = new IlrXMLRSMBindingObjectImpl();
binding.setBindingComplement("pathTo/ScenarioFile.xml");
// Initialize the element with the correct wrapper
IlrScenarioImpl element = new
IlrScenarioImpl((IlrScenarioWrapperImpl)binding.fromBinding());
// Return the element that extends the JUnit TestSuite class
return element;
}
}
Then, write the correct Ant task to run the JUnit class written previously, by either:
java:
In either case, you have to specify the Java library and configuration files to use in the classpath property:
rsmEmptyGridTemplate.xls (used to write in/out parameters in Excel)
rsmReportTemplate.xls (used to write Excel reports)
Scenario.rptdesign (used to write scenario reports in HTML or PDF)
Simulation.rptdesign (used to write simulation reports in HTML or PDF)
Suite.rptdesign (used to write scenario suite reports in HTML or PDF).
bin directory (or the library) issued from the compilation of the JUnit class written previously.
An example of an Ant execution is the following:
<!-- =================================================================== -->
<!-- Run in text mode -->
<!-- =================================================================== -->
<target name="run.text" description="Run the unit tests in text mode">
<java classname="junit.textui.TestRunner">
<arg line=" mypackage.MyScenarioJUnit"/>
<classpath refid="jrules.classpath" />
<classpath path="${basedir}/bin/." />
<classpath>
<pathelement location="${basedir}/lib/xom.jar"/>
</classpath>
<!-- Localization of scenarios files -->
<classpath path="${basedir}/data/scenario/." />
<classpath path="${basedir}/data/scenario/reports/excel/." />
<!-- Localization of the configuration and template files -->
<classpath path="${basedir}/config/." />
<classpath path="${basedir}/templates/." />
</java>
</target>
| Note |
The above can be used to execute scenario suites and simulations, replacing occurrences of Scenario in the code with ScenarioSuite or Simulation.
|
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |