Write a test class



An empty test class looks like this:

/*
* MyTest.java
*
*/
import de.tum.binfo.proj.engine.EngineResults;

public class MyTest extends Test {

    public MyTest() {
        super();
    }

    /**
     * @param data the result created by an engine
     * @throws Exception
     */
    public MyTest(EngineResults data) throws Exception {
        super(data);
    }

    /**
     * @param data the result created by an engine
     * @param testParams the settings made in the test dialog
     */
    public MyTest(EngineResults data, String testParams) {
        super(data, testParams);
     }

    /**
     * @param data the result created by an engine
     * @param testParams the settings made in the test dialog
     * @param prefix the value of the Dataselect field
     */
    public MyTest(EngineResults data, String testParams, String prefix) {
        super(data, testParams, prefix);
    }

    protected void setParameter() {
    }

    public String toString() {
        return null;
    }

    public int hashCode() {
        return 0;
    }

    public void run() throws Exception {
    }
}

If you want to perform a test and choose one from the menu, a dialog will be shown where the parameters can be set for the test. The content will be created from the test class itself, so this data has to be included in the class. This is realized in the setParameter()method. It sets the values for the paramDescription field of the superclass Test. If the test is loaded it creates a TestCustomizer and assembles the frame from the data provided in the paramDescription field.See javadoc for de.tum.binfo.proj.statistic.pdef.* for information about how to use the data. When a test is performed, the run() method is invoked. A typical run() method might look like this:

public void run() throws Exception {
    RParser p = new RParser();
    String statement =
    "testm = as.matrix(data)\n"
        + "ret = quade.test("
        + testParams
        + ")\n";
    performTest(statement);
    output = p.parseROutput(getProcessingMessages());
}
First, you need an instance of RParser which parseROutput(String) will parse the output of R for a better representation. Then the string which contains the R statement. It consists of the R syntax for this test and includes the test parameters (testParams) provided by the TestCustomizer.
The test will be executes by calling performTest(String) from the superclass Test which assembles the complete R statement for the test and pipes it to R.
Finally call the parseROutput(String) method which returns a Hashtable with the results. These results will now be available by calling getTestResults().