Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Maven establishes an organization for tests. These go into the directory tests in the project root area. The test should have the same package as the class it is testing in order that classes in the package can be accessed easily without a lot of import statements. All classes that extend junit.framework.TestSuite will be executed when Maven builds the project.

Accessing Test Data

Class Resources

File Cache

For data that is too large to embed into the org.lcsim jar file, the file cache can be used to download and access files.

No Format

import org.lcsim.util.cache.FileCache;

This shows how to download an LCIO file from an example URL.

No Format

URL url = new URL("http://www.example.com/mytestdata/someTestData.slcio");
FileCache cache = new FileCache();
File file = cache.getCachedFile(url);

Now use the Java File object as usual, as it should point to a local file on the user's system.

Actual test data is kept at *http://www.lcsim.org/datasamples*Image Added, which can be browsed. Your test data can also be added here. Contact jeremy@slac.stanford.edu if you want to upload your own test data.

Using the Event Loop

Many test cases need to use the org.lcsim event loop to execute a driver over some events.

Assuming that the file variable points to a cached Lcio file, an event loop can be setup and executed as follows.

No Format

LCSimLoop loop = new LCSimLoop();
loop.setLCIORecordSource(file);
loop.add(new MyTestDriver());
loop.loop(maxEvents);
loop.dispose();

Replace "MyTestDriver" with an actual driver you are trying to test.

A Real Example: HitPositionTest