The following script is generated by importing a sample JUnit 3.8.x test case and selecting the three methods testRound, testSqrt, and testMax:
transaction TInit var hPerf : number; begin JavaCreateJavaVM(); JavaSetString(JAVA_STATIC_METHOD, "TestCaseName"); ghTestObj := JavaLoadObject("JUTestClass", "JUTestClass.<init>"); end TInit; transaction TMain begin JUnitCallMethod(ghTestObj, "testRound", "testRound"); JUnitCallMethod(ghTestObj, "testSqrt", "testSqrt"); JUnitCallMethod(ghTestObj, "testMax", "testMax"); end TMain; transaction TEnd begin JavaFreeObject(ghTestObj); end TEnd;
JavaLoadObject in the TInit transaction instantiates the JUnit test class, JUTestClass.
JUnitCallMethod in the TMain transaction calls one of the three test methods in the same way that a JUnit test runner would. First the setUp() method is invoked, then the test method itself (e.g., testSqrt()), finally the tearDown() method is invoked.
When an optional timer parameter is specified for a Java method call, the execution times of the constructor, test method, setup method, and teardown method are measured. For the example in this topic, you receive the following measures: