Java Code Examples for junit.framework.TestSuite#run()
The following examples show how to use
junit.framework.TestSuite#run() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SecurityTestSupport.java From groovy with Apache License 2.0 | 5 votes |
protected void executeTest(Class test, Permission missingPermission) { TestSuite suite = new TestSuite(); suite.addTestSuite(test); TestResult result = new TestResult(); suite.run(result); if (result.wasSuccessful()) { if (missingPermission == null) { return; } else { fail("Security test expected an AccessControlException on " + missingPermission + ", but did not receive one"); } } else { if (missingPermission == null) { new SecurityTestResultPrinter(System.out).print(result); fail("Security test was expected to run successfully, but failed (results on System.out)"); } else { //There may be more than 1 failure: iterate to ensure that they all match the missingPermission. boolean otherFailure = false; for (Enumeration e = result.errors(); e.hasMoreElements();) { TestFailure failure = (TestFailure) e.nextElement(); if (failure.thrownException() instanceof AccessControlException) { AccessControlException ace = (AccessControlException) failure.thrownException(); if (missingPermission.implies(ace.getPermission())) { continue; } } otherFailure = true; break; } if (otherFailure) { new SecurityTestResultPrinter(System.out).print(result); fail("Security test expected an AccessControlException on " + missingPermission + ", but failed for other reasons (results on System.out)"); } } } }
Example 2
Source File: RunUnitTests.java From annotation-tools with MIT License | 5 votes |
public static void main(String[] args) { TestSuite suite = new TestSuite(RunUnitTests.class); TestResult result = new TestResult(); suite.run(result); System.out.println( "AnnotationsTests ran with " + result.failureCount() + " failures and " + result.errorCount() + " errors. (" + result.runCount() + " successes.)"); }
Example 3
Source File: AnnotationsTest.java From annotation-tools with MIT License | 5 votes |
/** * Runs all the tests in {@link #allTests} and displays the failure and error * counts. */ public static void main(String[] args) { TestSuite suite = new TestSuite(AnnotationsTest.class); TestResult result = new TestResult(); suite.run(result); System.out.println( "AnnotationsTests ran with " + result.failureCount() + " failures and " + result.errorCount() + " errors. (" + result.runCount() + " successes.)"); }
Example 4
Source File: TestTCK.java From database with GNU General Public License v2.0 | 5 votes |
/** * Execute the stress tests a couple of times. * * @throws Exception */ public void test_stressTests() throws Exception { for (int i = 0; i < 100; i++) { final TestSuite suite = new TestSuite( TCKStressTests.class.getSimpleName()); suite.addTestSuite(TCKStressTests.class); suite.run(new TestResult()); } }
Example 5
Source File: TestInclude.java From database with GNU General Public License v2.0 | 5 votes |
/** * Execute the stress tests a couple of times. * * @throws Exception */ public void test_stressTests() throws Exception { for (int i = 0; i < 100; i++) { final TestSuite suite = new TestSuite( IncludeStressTests.class.getSimpleName()); suite.addTestSuite(IncludeStressTests.class); suite.run(new TestResult()); } }
Example 6
Source File: TestRunContainer.java From scipio-erp with Apache License 2.0 | 4 votes |
public boolean start() throws ContainerException { // configure log4j output logging if (logLevel != null) { int llevel = Debug.getLevelFromString(logLevel); for (int v = 0; v < 9; v++) { if (v < llevel) { Debug.set(v, false); } else { Debug.set(v, true); } } } // get the tests to run JunitSuiteWrapper jsWrapper = new JunitSuiteWrapper(component, suiteName, testCase); if (jsWrapper.getAllTestList().size() == 0) { throw new ContainerException("No tests found (" + component + " / " + suiteName + " / " + testCase + ")"); } boolean failedRun = false; for (ModelTestSuite modelSuite: jsWrapper.getModelTestSuites()) { Delegator testDelegator = modelSuite.getDelegator(); TestSuite suite = modelSuite.makeTestSuite(); JUnitTest test = new JUnitTest(); test.setName(suite.getName()); // create the XML logger JunitXmlListener xml; try { xml = new JunitXmlListener(new FileOutputStream(logDir + suite.getName() + ".xml")); } catch (FileNotFoundException e) { throw new ContainerException(e); } // per-suite results TestResult results = new TestResult(); results.addListener(new JunitListener()); results.addListener(xml); // add the suite to the xml listener xml.startTestSuite(test); // run the tests suite.run(results); test.setCounts(results.runCount(), results.failureCount(), results.errorCount()); // rollback all entity operations performed by the delegator testDelegator.rollback(); xml.endTestSuite(test); if (!results.wasSuccessful()) { failedRun = true; } // display the results Debug.logInfo("[JUNIT] Results for test suite: " + suite.getName(), module); Debug.logInfo("[JUNIT] Pass: " + results.wasSuccessful() + " | # Tests: " + results.runCount() + " | # Failed: " + results.failureCount() + " # Errors: " + results.errorCount(), module); if (Debug.importantOn() && !results.wasSuccessful()) { Debug.logInfo("[JUNIT] ----------------------------- ERRORS ----------------------------- [JUNIT]", module); Enumeration<?> err = results.errors(); if (!err.hasMoreElements()) { Debug.logInfo("None", module); } else { while (err.hasMoreElements()) { Object error = err.nextElement(); Debug.logInfo("--> " + error, module); if (error instanceof TestFailure) { Debug.logInfo(((TestFailure) error).trace(), module); } } } Debug.logInfo("[JUNIT] ------------------------------------------------------------------ [JUNIT]", module); Debug.logInfo("[JUNIT] ---------------------------- FAILURES ---------------------------- [JUNIT]", module); Enumeration<?> fail = results.failures(); if (!fail.hasMoreElements()) { Debug.logInfo("None", module); } else { while (fail.hasMoreElements()) { Object failure = fail.nextElement(); Debug.logInfo("--> " + failure, module); if (failure instanceof TestFailure) { Debug.logInfo(((TestFailure) failure).trace(), module); } } } Debug.logInfo("[JUNIT] ------------------------------------------------------------------ [JUNIT]", module); } } if (failedRun) { throw new ContainerException("Test run was unsuccessful"); } return true; }
Example 7
Source File: SuiteTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public void testInheritedTests() { TestSuite suite= new TestSuite(InheritedTestCase.class); suite.run(fResult); assertTrue(fResult.wasSuccessful()); assertEquals(2, fResult.runCount()); }
Example 8
Source File: SuiteTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public void testShadowedTests() { TestSuite suite= new TestSuite(OverrideTestCase.class); suite.run(fResult); assertEquals(1, fResult.runCount()); }
Example 9
Source File: SuiteTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public void testAddTestSuite() { TestSuite suite= new TestSuite(); suite.addTestSuite(OneTestCase.class); suite.run(fResult); assertEquals(1, fResult.runCount()); }