Example BDL Script for JUnit 3.8.x (legacy)

Script Example

The following script is generated by importing a sample JUnit 3.8.x test case and selecting the three methods testRound, testSqrt, and testMax:

Note: The following script is a legacy script, which is generated within older Silk Performer versions. For Silk Performer 19.5 and newer, a JUnit import creates a slightly different script, which is documented in Example BDL Script for JUnit .
transaction TInit
    hPerf : number;
    JavaSetString(JAVA_STATIC_METHOD, "TestCaseName");
    ghTestObj := JavaLoadObject("JUTestClass", "JUTestClass.<init>");
end TInit;

transaction TMain
    JUnitCallMethod(ghTestObj, "testRound", "testRound");
    JUnitCallMethod(ghTestObj, "testSqrt", "testSqrt");
    JUnitCallMethod(ghTestObj, "testMax", "testMax");
end TMain;

transaction TEnd
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:

  • For the constructor: JUTestClass.<init>
  • For the methods: testRound, testSqrt, testMax
  • For the set up methods: testRound_setup, testSqrt_setup, testMax_setup
  • For the tear down methods: testRound_tearDown, testSqrt_tearDown, testMax_tearDown