Versions Compared

Key

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

...

All of the source, configuration, and data files needed for unit tests are located in the src/test directory within the OpenSAML 2 source tree. Unit test classes should be located, in a package structure that mirrors the class being tested, as a direct child of the test in the src/test/java directory. For example, a unit test exercising the class org.opensaml.saml1.core.impl.ResponseMarshaller would be located in the directory src/test/java/org/opensaml/saml1/core/impl . Data files needed for the test are placed in the same package based directory but are rooted in the src/test/resources/data directory. Using the example above, test data files for ResponseMarshaller test would be located in src/test/resources/data/org/opensaml/saml1/core/impl . The conf src/test/resources directory also contains OpenSAML 2 configuration files used during tests.

...

Extending BaseTestCase gives access to xmlUnit's assertion, the most useful of which is assertXMLEqual(Document, Document). This allows documents to be compared for equality (obviously). This is needed because serializing documents and doing string comparisons will normally fail because attributes can be in a different order in each case.

Executing the Tests

The ant build script provides the target test which standard maven command test will execute the unit tests.

...

Located directly under the src/test/resources directory is a log4j configuration file. This log4j file controls the logging output, probably the most useful point is on line 56 where you can set the logging prioritylogback configuration file used when testing.