How to write tests for a role

Step 1
Create a class within the IAccessAdapter-subinterface, and let this class implement the interface de.uni_koeln.spinfo.tesla.annotation.adapter.IAccessAdapterTest. The following code is taken from the test class within de.uni_koeln.spinfo.tesla.annotation.adapter.IAccessAdapter:

class AdapterTest implements IAccessAdapterTest<IAccessAdapter<DataObject>> {

                private IAccessAdapter<DataObject> adapter;

                public void initialize(IAccessAdapter<DataObject> adapter) {
                        this.adapter = adapter;
                }
...

Note that the class should not be public, to hide it from developers using the access adapter.

Step 2
Parameterize the generics according to the class under test. Than, add tests for all testable methods of the interface. These methods should be private, and must be annotated with org.junit.Test. Also add JUnit-assertions, as shown below:

                @SuppressWarnings({ "unused"})
                @Test
                private void testExperimentId() {
                        int experimentId = adapter.getExperimentId();
                        assertTrue("The experiment id is not set!", experimentId != 0);
                        assertTrue("The experiment id is not set!", experimentId != -1);
                }
Step 3
To execute the tests, create an experiment, and add Tesla's testing component (de.uni_koeln.spinfo.tesla.components.componenttester.ComponentTester) to it. Connect the component to test with the testing component, and execute the experiment.

testing_1.png
Step 4
The testing component will run each test of each test class in the interface hierarchy, and generate a report about the results (as well as test-result annotations).

testing_2.png
Comments
Note that these tests are not real unit-tests, as they depend on the configuration of the experiment: A test might fail because of a badly-configured experiment, or because the component under test could not generate usable results from the chosen input: A date detector cannot produce annotations if the processed texts did not contain dates. Thus, failed and passed tests have to be interpreted manually.
Also note that tests might be long-running, as their execution time usually depends on the number of generated annotations. Therefore, it is recommended to run tests on small document selections only. By default, tests have a timeout, such that they will be interrupted after a configurable period of time.