From Dogtag
Jump to: navigation, search


PKI uses JUnit framework to write unit tests.

Writing tests

In JUnit 4 it's no longer necessary to extend from TestCase class. The test methods can be marked using @Test annotation.

public class PrintableConverterTest {

    public void setUp() { ... }

    public void test1() throws Exception { ... }

    public void test2() throws Exception { ... }

    public void test3() throws Exception { ... }

    public void tearDown() { ... }

Running tests

JUnit provides a command-line to run the tests:

java -cp <classpath> org.junit.runner.JUnitCore [Test classes...]

However, the standard tool does not generate test reports. A new tool has been provided to run the tests and generate reports:

java -cp <classpath> -Djunit.reports.dir=<report dir> com.netscape.test.TestRunner [Test classes...]

See also Running Unit Tests in CMake.