Unit Tests

If you are interested in working with the Portico unit testing suite, it is assumed that you have already obtained the current development source code via the Subversion repository (as described in Source Code).

The unit tests are split into two separate groups: the Java interface tests and the C++ interface tests. Each is discussed below.

The Java Unit Tests
The run the java tests, all you will need is to have gotten the source code from Subversion (see Source Code). The Portico codebase includes everything else that is required.

The Java tests are currently split into 3 sub-groups:


 * 1) Tests for Portico internals (not many)
 * 2) Tests for the HLA 1.3 interface
 * 3) Tests for the HLA 1516 interface

If you want to run all the tests, you can issue the following command and you should see something like the provided output:

[tim@zapp:portico]$ cd codebase/ [tim@zapp:codebase]$ ./ant java.test Buildfile: build.xml

init: [echo] Building portico

java.compile.init: [echo] Compiling java source code... [mkdir] Created dir: /Users/tim/Documents/workspace/portico/codebase/build/java [mkdir] Created dir: /Users/tim/Documents/workspace/portico/codebase/build/java/classes [echo] JAVA VERSION: 1.5.0_13 [echo] debug / debug level: true / lines,vars,source [echo] source compat: 1.5

java.compile.production: [javac] Compiling 646 source files to /Users/tim/Documents/workspace/portico/codebase/build/java/classes

java.compile.tests: [mkdir] Created dir: /Users/tim/Documents/workspace/portico/codebase/build/java/test [mkdir] Created dir: /Users/tim/Documents/workspace/portico/codebase/build/java/test/classes [javac] Compiling 74 source files to /Users/tim/Documents/workspace/portico/codebase/build/java/test/classes

java.test.init: [echo] Starting unit testing... [mkdir] Created dir: /Users/tim/Documents/workspace/portico/codebase/build/java/test/reports

java.test.portico: [echo] =============================================== [echo]   Executing Test Suite: portico [echo] =============================================== [mkdir] Created dir: /Users/tim/Documents/workspace/portico/codebase/build/java/test/reports/portico [testng]     parseValidHla13Fom [testng]     testXMLCheckerOnNonExistentFile [testng]     testPropertyLoaderExceptions [testng]     testPropertyLoader [testng]     testXMLCheckerOnExistingFiles [testng] [testng] =============================================== [testng] Command line suite [testng] Total tests run: 5, Failures: 0, Skips: 0 [testng] =============================================== [testng]

java.test.13: [echo] =============================================== [echo]   Executing Test Suite: hla13 [echo] =============================================== [mkdir] Created dir: /Users/tim/Documents/workspace/portico/codebase/build/java/test/reports/hla13 [testng]     testNerWhileConstrainedAndRegulating [testng]     testNerResetsWhenAllResign [testng]     testNerWithWithTimeInPast [testng]     testNerWithNegativeTime [testng]     testNerWhenEventTimestampIsLessThanRequested [testng]     testNerWhileRegulationIsPending [testng]     testNerWhenNoTsoEventsAreQueued

... ... ...

BUILD SUCCESSFUL Total time: 3 seconds

If you only want to run one set of the tests, you can issue any of the following commands depending on which set you are wanting:

./ant java.test.13 (HLA 1.3 tests) ./ant java.test.1516 (HLA 1516 tests) ./ant java.test.portico (Portico internals tests)

Test Groups
For each set, the contained unit tests themselves are grouped into smaller categories based on their HLA functionality. For example, the time advancement methods (, , etc...) are all tagged with the group names   and. When the unit tests are executed, a group (or set of groups) can be specified. Only tests tagged as being in at least one of those groups will be executed.

To specify a set of test groups, you use the  system property from the command line.

Thus, if you only wanted to run the time advancement tests, you would issue the something like the following:

[tim@zapp codebase]$ ./ant java.test.13 -Dtest.groups=advance

and you would get:

[tim@zapp:codebase]$ ./ant java.test.13 -Dtest.groups=advance Buildfile: build.xml

init: [echo] Building portico

java.compile.init: [echo] Compiling java source code... [echo] JAVA VERSION: 1.5.0_13 [echo] debug / debug level: true / lines,vars,source [echo] source compat: 1.5

java.compile.production:

java.compile.tests:

java.test.init: [echo] Starting unit testing...

java.test.13: [echo] =============================================== [echo]   Executing Test Suite: hla13 [echo] =============================================== [testng]     testTarWhileNotRegulatingOrConstrained [testng]     testTarWithNegativeTime [testng]     testTarWithNullTime [testng]     testTarWhileConstrainedAndRegulating [testng]     testTarWithRegulatingConstrainedAndNeither [testng]     testTarWhileRegulatingOnly [testng]     testTarWithRegulatingResign [testng]     testTarWhileRegulationIsPending [testng]     testTar [testng]     testTarWithMultipleRegulatingAndConstrained [testng]     testTarResetsWhenAllResign [testng]     testTarWithTimeInPast [testng]     testTarWhileConstrainedOnly [testng]     testTarEnforcesLookahead [testng]     testTarWithSingleRegulatingAndConstrained [testng]     testTarWhileConstrainedIsPending [testng]     testTarWhenNotJoined [testng]     testTarWhileAnotherTarIsOutstanding [testng]     testNerWhileRegulatingOnly [testng]     testNerWhenEventTimestampIsLessThanRequested [testng]     testNerWhileConstrainedIsPending [testng]     testNerWhenNoTsoEventsAreQueued [testng]     testNerWithNegativeTime [testng]     testNerWhileNotRegulatingOrConstrained [testng]     testNerWithRegulatingResign [testng]     testNer [testng]     testNerWhileConstrainedAndRegulating [testng]     testNerWhileConstrainedOnly [testng]     testNerWithOutstandingTimeAdvance [testng]     testNerEnforcesLookahead [testng]     testNerWhileRegulationIsPending [testng]     testNerResetsWhenAllResign [testng]     testNerWithWithTimeInPast [testng]     testNerWhenEventTimestampIsGreaterThanRequested [testng]     testNerWithNullTime [testng]     testNerWhenNotJoined [testng] [testng] =============================================== [testng] Command line suite [testng] Total tests run: 36, Failures: 0, Skips: 0 [testng] =============================================== [testng]

BUILD SUCCESSFUL Total time: 29 seconds

To specify more than one group, just use a comma-separated list.

See the TestNG website for more information on test groups.

Test Log Levels
By default, the testing framework turns off all RTI logging during the unit testing process. This is necessary to prevent the overwhelming amount of information that would otherwise be generated. If you would like access to this logging information, you can control the log level via the  system property.

[tim@zapp codebase]$ ./ant java.test -Dtest.loglevel=TRACE

The C++ Unit Tests
The C++ Unit Tests currently only cover the HLA 1.3 C++ user interface.

To run these tests there are a couple of additional installation requirements. You will need to have installed:


 * 1) A C++ compiler (GCC4 and VC6 used by core developers)
 * 2) CppUnit (v1.12.0 used by core developers)

CppUnit
These tests use CppUnit. Sadly, CppUnit only comes as a source distribution, so you will have to download and compile it yourself. Once installed, you need to tell the Portico build where CppUnit is located. You have two options for this.

First, you can install it in a location where the system can find it. On Linux/Mac OS X this generally just involves doing the typical "./configure;make;make install" routine.

For windows you will have to manually specify the location where you installed CppUnit (you can also do this for Linux/Mac OS X if you want). You do this build setting the "cppunit.home" build property. Just create the file "build.properties" in the codebase and put the string "cppunit.home=/path/to/install" in it. The Portico build system will pick up this file and get the setting from it. The build will complain if the property has not been set.

The Tests
The source code for the C++ unit tests is located in the  directory.

To run the C++ unit tests, you would use the  target:

[tim@zapp:codebase]$ ./ant cpp.test

Like the Java tests, the C++ interface tests are broken down into smaller groups. To select a particular group of tests to run, issue the following command:

./ant cpp.test -Dtest.group=TimeAdvanceRequestTest

Note that the property name is test.group (not "groups"). The names of the groups correspond to the various C++ class that implements the test. Replace the group name with whichever test class you want to run.

Writing Unit Tests
See Writing Unit Tests.