com.metamatrix.script.junit
Class BshTestSuite

java.lang.Object
  extended by junit.framework.TestSuite
      extended by com.metamatrix.script.junit.BshTestSuite
All Implemented Interfaces:
junit.framework.Test

public class BshTestSuite
extends junit.framework.TestSuite

TestSuite class to be used with the BeanShell unit tests. This class given the script name, aggregates all the test methods in the script and add them to the current suite as test cases. This class needs to be used in conjunction with the BshTestCase.

 public MyTest extends TestCase{
 
     public static Test suite() {
                   BshTestSuite suite = new BshTestSuite();
                   suite.addTest("JUnitTest.bsh");
                   suite.addTest("Math.bsh");
                   return suite;
     }
 }
 
During debugging, when you want to execute a single test method, or group of test methods, you can select a predefined tests by two ways.

One: In the ".bsh" script add a variable called "runOnly=*" like, and supply a regular expression which matches to the test name, or test name itself.

  runOnly = ".*One"; // Regular Expression
  testMethodOne(){
      //test case 1
  }
  testMethodTwo(){
      // test case 2
  }
 

Two: There is a overridden "addTest" method on the BshTestSuite, which will take a regEx or method name.

 public MyTest extends TestCase{ 
     public static Test suite() {
         BshTestSuite suite = new BshTestSuite();
         suite.addTest("JUnitTest.bsh", ".*One");
         suite.addTest("Math.bsh");
         return suite;
     }
 }
 
Currently the path to the script must be relative to the working directory or fully qualified.

See Also:
BshTestCase

Constructor Summary
BshTestSuite()
           
BshTestSuite(java.lang.String name)
           
 
Method Summary
 void addTest(java.lang.String bshScript)
          Loads the specified script from the classpath.
 void addTest(java.lang.String bshScript, java.lang.String methodNamePattern)
          A way add a single test while debugging.
 
Methods inherited from class junit.framework.TestSuite
addTest, addTestSuite, countTestCases, createTest, getName, getTestConstructor, run, runTest, setName, testAt, testCount, tests, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BshTestSuite

public BshTestSuite()

BshTestSuite

public BshTestSuite(java.lang.String name)
Method Detail

addTest

public void addTest(java.lang.String bshScript)
Loads the specified script from the classpath.

Parameters:
bshScript - Name of the test beanshell file in the classpath.
See Also:
TestSuite.addTest(junit.framework.Test)

addTest

public void addTest(java.lang.String bshScript,
                    java.lang.String methodNamePattern)
A way add a single test while debugging.

Parameters:
bshScript -
methodName -
Since:
4.3


Copyright © 2009. All Rights Reserved.