Skip to content

Creating an Integration Test

sheldonabrown edited this page Jul 26, 2013 · 5 revisions

An Integration test consists of running an inference trace combined with a bundle in an automated fashion. The inference trace format supports expected results, which the integration tests framework then verifies if present. This allows verification of the inference process.

Follow the simple steps below to add an integration test.

Add trace file

Add a trace of the activity to this directory:

onebusaway-nyc/onebusaway-nyc-integration-tests/src/integration-test/resources/traces

Go to create a trace to better understand the trace format.

Add GTFS

If the bundle was build with the onebusaway-nyc-admin-webapp, the inputs directory of the bundle associated with this trace will contain the original GTFS. Place the GTFS in a directory named after the bundle ({BUNDLE_NAME}) in this directory:

onebusaway-nyc/onebusaway-nyc-integration-tests/src/integration-test/resources/bundle/gtfs

You may pair down the GTFS to what is appropriate to increase the speed of the integration test.

Add external source data

Occasionally other source data is combined with the GTFS to aid in inference. If any external data is required, add it in a subdirectory of

onebusaway-nyc/onebusaway-nyc-integration-tests/src/integration-test/resources/bundle/

Again, name the directory based on the name of the bundle.

Create test file in location

Create a Java file that extends AbstractTraceRunner in the following location:

onebusaway-nyc/onebusaway-nyc-integration-tests/src/test/java/org/onebusaway/nyc/integration_tests/vehicle_tracking_webapp/cases

of format:

package org.onebusaway.nyc.integration_tests.vehicle_tracking_webapp.cases;

import org.onebusaway.nyc.integration_tests.vehicle_tracking_webapp.AbstractTraceRunner;

/**
 * Describe the situation this trace is testing for.
 *
 */
public class Trace_{TRACE_NAME}_IntegrationTest extends AbstractTraceRunner {

  public Trace_{TRACE_NAME}_IntegrationTest() throws Exception {
    super("{TRACE_NAME}.csv");
    // Date format is 2013-07-15T19:40:00EDT
    setBundle("{BUNDLE_NAME}", "{TIME_OF_START_OF_TRACE}");
  }
}

Add to TestSuite

For performance reasons, the integration tests are run in a set order. This minimizes the number of bundle swaps necessary. Due to this however, new integration tests need to be manually added to the TestSuite. they are not discovered automatically.

To add a new integration tests to the TestSuite, edit

onebusaway-nyc/onebusaway-nyc-integration-tests/src/test/java/org/onebusaway/nyc/integration_tests/TestSuite.java

and add the class to the list of SuiteClasses in the appropriate location.

Run integration tests

Test that the work you did above passes:

user@localhost:~src/onebusaway-nyc$ mvn clean install

Commit and push

user@localhost:~src/onebusaway-nyc$ git commit -a -m "adding integration tests {TRACE_NAME}" && git push
Clone this wiki locally