com.mockrunner.test.consistency.Launcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockrunner-jdk1.3-j2ee1.3 Show documentation
Show all versions of mockrunner-jdk1.3-j2ee1.3 Show documentation
Mockrunner is a lightweight framework for unit testing applications
in the J2EE environment. It supports servlets, filters, tag classes
and Struts actions. It includes a JDBC a JMS and a JCA test
framework and can be used to test EJB based applications.
The newest version!
package com.mockrunner.test.consistency;
import java.lang.reflect.Method;
import junit.framework.Test;
import junit.framework.TestResult;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
public class Launcher
{
public void run(String testClassName) throws Exception
{
Class testClass = this.getClass().getClassLoader().loadClass(testClassName);
Test test = null;
if(!Test.class.isAssignableFrom(testClass))
{
Method method = testClass.getMethod("suite", null);
test = (Test)method.invoke(null, null);
}
else
{
test = new TestSuite(testClass);
}
TestResult result = TestRunner.run(test);
if(!result.wasSuccessful())
{
throw new RuntimeException("Test " + testClassName + " failed");
}
}
}