Calling entity loaders and event sequences

You can include entity loaders and event sequences in unit tests for automated testing by using the entitySource and the eventSource interfaces.

Before you begin

When you set up your test environment, you can use all of the TestDriver properties to load entities and submit events. By using the TestDriver API methods, you can, for example, create a test that loads several entity loaders or submits several event sequences. You must also set the properties that are otherwise set by the launch configuration wizards 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

You load entities and submit events that are in a test client project. You can add the bomProjectPath and testClientProjectPath properties to the testdriver.properties file. Then, you can set up a unit test that uses the EntitySource and the EventSource interfaces:
  • EntitySource<Entity> createEntityLoaderEntitySource(String <Entity Loader>)
  • EventSource<Event> createEventSequenceEventSource(String <Event Sequence>)

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: In the testdriver.properties file, set the testClientProjectPath property to point to the test client project that contains the entity loaders and event sequences that you want to test. If you do not set this property, TestDriver uses the working directory of your test client.
  3. Load a set of entities by creating an entity loader EntitySource and calling the loadEntities(Iterator<Entity>) method in your TestDriver class. The following example loads an entity loader named customers:
    EntitySource<Entity> entitySource = 
    testDriver.createEntityLoaderEntitySource("customers"); 
    
    testDriver.loadEntities(entitySource.iterator());
  4. Run event sequences by creating an event sequence EventSource and calling the submitEvents(Iterator<Event>) method in your TestDriver class. The following example submits an event sequence named transactions:
    EventSource<Event> eventSource =
    testDriver.createEventSequenceEventSource("transactions");
    
    testDriver.submitEvents(eventSource.iterator());
  5. 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.