Calling test scenarios as part of an automated test

You can include test scenarios in unit tests for automated testing by using the testDriver.runTestScenario() method.

Before you begin

When you set up your test environment, you can use all of the TestDriver properties to call test scenarios. By using the TestDriver API methods, you can, for example, create a test that loads several test scenarios. You must also set the properties that are otherwise set by the launch configuration wizard in Insight Designer. For example, you must set the test epoch and (optionally) reset the solution state when you use the TestDriver API methods.

About this task

To call a test scenario, you can add the bomProjectPath and testClientProjectPath properties to the testdriver.properties file. Then, you can set up a unit test that calls the runTestScenario(String <Test Scenario>) method.

Procedure

  1. Optional: Set the bomProjectPath property in the testdriver.properties file to point to your solution BOM. For example: bomProjectPath=../MyCreditCardSolutionBOM. By default, this property points to the BOM in your solution.
  2. Optional: If you want to start a test client application that is outside of your working directory, set the testClientProjectPath property in the testdriver.properties file to point to the test client project that contains your test scenario. If you do not set this property, the default location is the test client project in your working directory.
  3. Add the runTestScenario(String <Test Scenario>) method to your test client. The following example runs a test scenario named account statuses with the test epoch property set to February 1 2016:
    @Test
    public void testRunTestScenario() {
    testDriver.setTestEpoch("2016-02-01T00:00Z");
    testDriver.runTestScenario("account statuses");
    }
  4. Run the test client as a JUnit test.

What to do next

After you call the test scenario by using TestDriver, check the output in the Console view or in the logs. You can also check the results in Insight Map Viewer, Insight Inspector, and Insight Monitor. If any part of the test scenario execution fails, a TestDriverException is thrown. The message of this exception contains information about what step of the test scenario causes the failure.