I want to execute a junit testcase inside another java program.. Let’s say
class XYZ extends TestCase{
public void test1(){}
public void test2(){}
public void test3(){}
}
Like the way I run this unit test on eclipse, I want to be able to execute this at run time..I need to know the number of tests passed and failed.. I tried the typical java way of doing this by creating an object of this testcase class and invoking each function one by one but somehow I felt it is ineffective to do so.. Also, it does execute the tests but doesn’t tell me anything about the statistics about tests passed and failed..
So how can I execute all this tests at run time within another java program, mimicking what eclipse does?
You can use the JunitCore class to execute tests programmatically. This will return a Result which you will have to evaluate for yourself.