use of junit.framework.TestResult in project eclipse.platform.runtime by eclipse.
the class MultipleRunsTest method testMultipleRuns.
public void testMultipleRuns() throws SetupManager.SetupException {
// the test case to run multiple times
TestDescriptor test = new TestDescriptor(SampleSessionTest.class.getName(), "testApplicationStartup");
test.setApplicationId(SessionTestSuite.CORE_TEST_APPLICATION);
test.setPluginId(CoreTest.PI_HARNESS);
test.setTestRunner(new SessionTestRunner());
// setup the command line to be passed to the multiple runs so it has the right system properties
test.setSetup(SetupManager.getInstance().getDefaultSetup());
test.getSetup().setSystemProperty("eclipse.perf.dbloc", System.getProperty("eclipse.perf.dbloc"));
test.getSetup().setSystemProperty("eclipse.perf.config", System.getProperty("eclipse.perf.config"));
// runs the test case several times - only to collect data, won't do any assertions
TestResult result = new TestResult();
for (int i = 0; i < 5; i++) {
test.run(result);
if (result.failureCount() > 0) {
result.failures().nextElement().thrownException().printStackTrace();
return;
}
if (result.errorCount() > 0) {
result.errors().nextElement().thrownException().printStackTrace();
return;
}
}
// create a performance meter whose scenario id matches the one used in the test case run
// our convention: scenario IDs are <test case class name> + '.' + <test case method name>
PerformanceMeter meter = Performance.getDefault().createPerformanceMeter(test.getTestClass() + '.' + test.getTestMethod());
// finally do the assertion
Performance.getDefault().assertPerformanceInRelativeBand(meter, Dimension.ELAPSED_PROCESS, -50, 5);
}
use of junit.framework.TestResult in project tomee by apache.
the class TestRunner method main.
/**
* main entry point.
*/
public static void main(final String[] args) {
if (args.length == 0) {
printHelp();
} else {
if (args[0].equals("--help")) {
printHelp();
return;
} else if (args[0].equals("local")) {
runLocalTests();
} else if (args[0].equals("remote")) {
runRemoteTests();
} else if (args[0].equals("http")) {
runRemoteHttpTests();
} else if (args[0].equals("tomcat")) {
runTomcatRemoteHttpTests();
} else {
printHelp();
return;
}
try {
final TestRunner aTestRunner = new TestRunner();
final TestResult r = aTestRunner.start(new String[] { "org.apache.openejb.test.ClientTestSuite" });
System.out.println("");
System.out.println("_________________________________________________");
System.out.println("CLIENT JNDI PROPERTIES");
final Properties env = TestManager.getServer().getContextEnvironment();
for (final Iterator iterator = env.entrySet().iterator(); iterator.hasNext(); ) {
final Map.Entry entry = (Map.Entry) iterator.next();
final String key = (String) entry.getKey();
final Object value = entry.getValue();
System.out.println(key + " = " + value);
}
System.out.println("_________________________________________________");
if (!r.wasSuccessful())
System.exit(FAILURE_EXIT);
System.exit(SUCCESS_EXIT);
} catch (final Exception e) {
System.err.println(e.getMessage());
System.exit(EXCEPTION_EXIT);
}
}
}
use of junit.framework.TestResult in project guava by google.
the class FeatureSpecificTestSuiteBuilderTest method testLifecycle.
public void testLifecycle() {
boolean[] setUp = { false };
Runnable setUpRunnable = new Runnable() {
@Override
public void run() {
setUp[0] = true;
}
};
boolean[] tearDown = { false };
Runnable tearDownRunnable = new Runnable() {
@Override
public void run() {
tearDown[0] = true;
}
};
MyTestSuiteBuilder builder = new MyTestSuiteBuilder();
Test test = builder.usingGenerator("yam").named("yam").withFeatures(CollectionFeature.NONE).withSetUp(setUpRunnable).withTearDown(tearDownRunnable).createTestSuite();
TestResult result = new TestResult();
test.run(result);
assertTrue(testWasRun);
assertTrue(setUp[0]);
assertTrue(tearDown[0]);
}
use of junit.framework.TestResult in project mondrian by pentaho.
the class CacheHitTest method runTestSuiteInOrder.
/**
* Loops <code>numIte</code> times, each time run all child test
* suite in the <code>suite</code>
*
* @param suite the suite of test suites
* @param numIter number of iterations
* @throws Exception on error
*/
public void runTestSuiteInOrder(TestSuite suite, int numIter) throws Exception {
final TestResult tres = new TestResult();
final MondrianServer server = MondrianServer.forConnection(getTestContext().getConnection());
for (int i = 0; i < numIter; i++) {
TestSuite test = (TestSuite) suite.testAt(i % suite.testCount());
for (int j = 0; j < test.testCount(); j++) {
test.testAt(j).run(tres);
}
}
report(server.getMonitor().getServer());
}
use of junit.framework.TestResult in project nutz by nutzam.
the class AdvancedTestAll method test.
public static TestResult test(List<Request> reqs, String name, Map<Request, Method> reqMap) {
// TODO 根据order文件还原测试顺序
try {
FileWriter fw = new FileWriter("./test_order_" + name + ".txt");
for (Request request : reqs) {
fw.write(reqMap.get(request).toString());
fw.write("\n");
}
fw.flush();
fw.close();
} catch (IOException e) {
}
final TestResult result = new TestResult();
RunNotifier notifier = new RunNotifier();
notifier.addListener(new RunListener() {
public void testFailure(Failure failure) throws Exception {
result.addError(asTest(failure.getDescription()), failure.getException());
}
public void testFinished(Description description) throws Exception {
result.endTest(asTest(description));
}
public void testStarted(Description description) throws Exception {
result.startTest(asTest(description));
}
public junit.framework.Test asTest(Description description) {
return new junit.framework.Test() {
public void run(TestResult result) {
throw Lang.noImplement();
}
public int countTestCases() {
return 1;
}
};
}
});
for (Request request : reqs) {
request.getRunner().run(notifier);
}
return result;
}
Aggregations