Problem running JUnit through BeanShell

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problem running JUnit through BeanShell

Tim Hiller
I am trying to run a beanshell script (bsh-2.0b4) containing the following code.  The intention is to allow JUnit test cases to be written/maintained without compiling.  I have tried this with JUnit 3.81 and 4.1.  I am on Java 1.4.2

Notes:
JUnit throws an AssertionError intentionally for the failed assert.  I believe it is expected to propagate its way up out of the test function but it looks like Beanshell is intercepting it.  Consequently I am seeing it as an "Error" rather than a "Failure" on the test results.  If I run the equivalent code without beanshell it reports as a failure.

Any help would be appreciated.

import junit.framework.TestCase;
import junit.framework.TestSuite;

public class MyTestCase
    extends TestCase
{
    public void testFailure()
    {
        assertEquals(2, 5);
    }

}


public class MyTestSuite
{
    public static TestSuite suite()
    {
        TestSuite suite = new TestSuite();
       
        suite.addTestSuite(MyTestCase.class);

        return suite;
    }


    public static void runTests()
    {
        junit.textui.TestRunner.run(suite());
    }
}

MyTestSuite.runTests();