About Java-testcases.
It is recommended to read the chapter 3.4 Professional UNO
and especially section 3.4.1 Java Language Binding
in the Developer's Guide before going further.
Implement a test for an implementation Object
A test for an implementation object has the following structure:
public class <ObjectName> extends TestCase {
protected void initialize( TestParameters tParam, PrintWriter log ) {
//initialization issues that have to be done previous to object creation
}
protected void cleanup( TestParameters tParam, PrintWriter log ) {
//dipose the environment, e.g close all documents opened during test
}
public TestEnvironment createTestEnvironment( TestParameters tParam, PrintWriter log )
throws StatusException {
XInterface oObj = null;
//create your Object (oObj) here.
//create a new TestEnvironment for your object
TestEnvironment tEnv = new TestEnvironment( oObj );
return tEnv;
} // finish method createTestEnvironment
}// finish class <ObjectName>
Thus, to implement an object creation you have to write a new class that extends TestCase
class. The main method that must be implemented is createTestEnvironment.
This method is called to create an object and return the TestEnvironment.
Additional parameters that are needed in the corresponding Interface/Service tests are also defined here and added to the
TestEnvironment with the method
addObjRelation(NameOfTheRelation,ValueOfTheRelation)
Tests for implemetation objects are store in the package “mod.<_module>”
and are called <ObjectName>,
e.g. a TestCase for “sw.SwXBodyText” will be stored in
the package “mod._sw” and will be called ”SwXBodyText.Java”.
To write debug information use log.println(msg);
Implement the corresponding Interface test
An interface test has the following structure:
public class <_XInterfaceName> extends MultiMethodTest {
public <XInterfaceName> oObj = null; //target to be queried by the framework
public void _method1() {
//Code for method1
tRes.tested("method1()",booleanResult);
}
public void _methodn() {
//Code for methodn
tRes.tested("methodn()",booleanResult);
}
}// finish class <_XInterfaceName>
<XInterfaceName> is the name of the interface to be queried (e.g. XText).
Procedures called _<method_name> will be called one by one. The variable oObj
will be initialized in createTestEnvironment
of the corresponding implementation object's TestCase.
The method tRes.tested of lib.TestResult returns a result for the method to the
Framework.
tRes.tested(String "<method_name>()", boolean result);
To get needed parameters that were created as
object-relation in the object's TestCase, the class lib.TestEnvironment provides
a method getObjRelation:
tEnv.getObjRelation(String "<NameOfTheRelation>");
Implement the corresponding Service test
In most cases to write a test for service you just have to write a class that
extends lib.MultiPropertyTest.
public class _<Service_Name> extends MultiPropertyTest {
}
MultiPropertyTest will test all properties automatically, using the inner class ValueChanger.
But, if you need to test some property in a special way, you
can overwrite a test function.
In this case you have to write:
public void _<property_name>() {
boolean result = true;
...
tRes.tested("<property_name>", result);
}
Last modified: $Date: 2004/03/10 15:58:38 $