$customHeader
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Testing Guide

OpenSAML 2, Java Edition, uses jUnit with the xmlUnit extension as its unit testing framework.

Test Source Layout

All of the source, configuration, and data files needed for unit tests are located in the 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 directory. For example, a unit test exercising the class org.opensaml.saml1.core.impl.ResponseMarshaller would be located in the directory test/org/opensaml/saml1/core/impl . Data files needed for the test are placed in the same package based directory but are rooted in the test/data directory. Using the example above, test data files for ResponseMarshaller test would be located in test/data/org/opensaml/saml1/core/impl . The conf directory contains OpenSAML 2 configuration files used during tests.

Writing a Unit Test

All unit test cases must be named !XxxTest.java where Xxx is the name of the class being tested and should extend org.opensaml.common.BaseTestCase. Test method names, within the unit test, must be named testXxx where Xxx is some descriptive name for the test. For those familiar with jUnit, no TestSuite is necessary.

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 will execute the unit tests.

Logging

Located directly under the test 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 priority.

  • No labels