Running a custom test

Define an application to override the default runner. It can connect to a data source, and use a custom display format.

About this task

In Rule Designer, you create a project to define a custom runner application that overrides the class ilog.rules.studio.testing.execution.DefaultRunner. The new application connects to a database and customizes the display of the results. You apply the application in the Testing Decision Operation run configuration.

Procedure

  1. Create a Java™ project with the custom runner application. The class must have a java main() method.
    Define the application as shown in the following CustomExcelRunner.java example:
    package custom;
    import java.io.IOException;
    import java.util.List;
    import com.ibm.rules.cdi.core.service.output.ScenarioResult;
    import ilog.rules.studio.testing.execution.DefaultRunner;
    import ilog.rules.studio.testing.execution.ExcelFileExecutionConfiguration;
    public class CustomExcelRunner {
    	static class CustomRunner extends DefaultRunner {
    		public CustomRunner() {
    			super();
    			System.out.println("CONNECT");
    		}
    		@Override
    		public void displayResults(ExcelFileExecutionConfiguration executionConfiguration,
    				List<ScenarioResult> results) {
    			super.displayResults(executionConfiguration, results);
    			System.out.println("ADD DISPLAY INFO...");
    		}
    	}	
        public static void main(String[] args) {
            try {
            	CustomRunner runner = new CustomRunner();
    	        ExcelFileExecutionConfiguration executionConfiguration = runner.createConfiguration(args);	        
    	        runner.run(args, executionConfiguration);
    	        System.exit(0);
            } catch (IOException e) {
    			e.printStackTrace();
    			System.exit(1);
    		}
        }
    }
    
  2. Add the required external .jar files to the Java build path in the project.
    Examples of external files:
    • execusionserver/lib/testingrunner.jar
    • execusionserver/lib/jrules-cdi-integration.jar
  3. Open Run Configurations in the toolbar.
  4. Select your decision operation under Testing Decision Operation.
  5. In the Classpath tab, add the path to the class CustomExcelRunner.java or its generated .jar file.
  6. In the Arguments tab, select custom.CustomExcelRunner as the main class.
    If you do not specify the main class, the default runner application is used.
  7. Click Run. The results are displayed in the console.