Skip to content

junit

Version 5 seems to be the choice, it can also handle junit 4 reports.

usage

It is rather like your own automated tests, you create a class that calls test functions in src/test/org/klopt/tools/TestSomething.java :

test file
package org.klopt.tools;

import org.junit.jupiter.api.Test;

class TestSomething {

    @Test
    void justAnExample() {
        System.out.println("This test method should be run");

        Ticker t = new Ticker(9,"","","","");
        assert (t != null);
    }

    @Test
    void anotherExample() {
        System.out.println("This test method should also run");

        Ticker t = new Ticker(9,"","","","");
        assert (t != null);
    }
}

So .. not public, no main, just the @Test annotations.

And the class to be tested just resides in the main directory : src/main/org/klopt/tools/Ticker.java

In that file the normal code should reside, there should be no tests in the main directory, just functions to-be-tested. @Test annotation in the main directory won' compile in the normal setup.

view test results

Thanx junit, just dump an xml file in build/test-results/junit-platform and let me google how to read it.

But this viewer will do :

junit-viewer
npm install -g junit-viewer
junit-viewer --results=build/test-results/junit-platform --port=9191

This will display the report on localhost port 9191 .