Java Code Examples for junit.framework.TestSuite#getName()

The following examples show how to use junit.framework.TestSuite#getName() . 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: Bigdata2ASTSPARQL11SyntaxTest.java    From database with GNU General Public License v2.0 6 votes vote down vote up
static TestSuite filterOutTests(final TestSuite suite1, final Collection<String> testURIs) {

        final TestSuite suite2 = new TestSuite(suite1.getName());
        final Enumeration<Test> e = suite1.tests();
        while (e.hasMoreElements()) {
            final Test aTest = e.nextElement();
            if (aTest instanceof TestSuite) {
                final TestSuite aTestSuite = (TestSuite) aTest;
                suite2.addTest(filterOutTests(aTestSuite, testURIs));
            } else if (aTest instanceof Bigdata2ASTSPARQL11SyntaxTest) {
                final Bigdata2ASTSPARQL11SyntaxTest test = (Bigdata2ASTSPARQL11SyntaxTest) aTest;
                if (!testURIs.contains(test.testURI)) {
                    suite2.addTest(test);
                }
            }

        }
        return suite2;
       
    }
 
Example 2
Source File: BigdataSparqlTest.java    From database with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Hack filters out the "dataset" tests.
 * 
 * @param suite1
 *            The test suite.
 * 
 * @return The test suite without the data set tests.
 */
static protected TestSuite filterOutTests(final TestSuite suite1, final String name) {

    final TestSuite suite2 = new TestSuite(suite1.getName());
    final Enumeration<Test> e = suite1.tests();
    while (e.hasMoreElements()) {
        final Test aTest = e.nextElement();
        if (aTest instanceof TestSuite) {
            final TestSuite aTestSuite = (TestSuite) aTest;
            if (!aTestSuite.getName().equals(name)) {
                suite2.addTest(filterOutTests(aTestSuite,name));
            }
        } else {
            suite2.addTest(aTest);
        }
    }
    return suite2;
   
}
 
Example 3
Source File: BigdataSparqlTest.java    From database with GNU General Public License v2.0 6 votes vote down vote up
static protected TestSuite filterOutTests(final TestSuite suite1, final Collection<String> testURIs) {

        final TestSuite suite2 = new TestSuite(suite1.getName());
        final Enumeration<Test> e = suite1.tests();
        while (e.hasMoreElements()) {
            final Test aTest = e.nextElement();
            if (aTest instanceof TestSuite) {
            	final TestSuite aTestSuite = (TestSuite) aTest;
                suite2.addTest(filterOutTests(aTestSuite, testURIs));
            } else if (aTest instanceof BigdataSparqlTest) {
                final BigdataSparqlTest test = (BigdataSparqlTest) aTest;
                if (!testURIs.contains(test.testURI)) {
                    suite2.addTest(test);
                }
            }

        }
        return suite2;
       
    }
 
Example 4
Source File: BigdataSPARQLUpdateConformanceTest.java    From database with GNU General Public License v2.0 6 votes vote down vote up
static TestSuite filterOutTests(final TestSuite suite1, final Collection<String> testURIs) {

        final TestSuite suite2 = new TestSuite(suite1.getName());
        @SuppressWarnings("unchecked")
        final Enumeration<Test> e = suite1.tests();
        while (e.hasMoreElements()) {
            final Test aTest = e.nextElement();
            if (aTest instanceof TestSuite) {
                final TestSuite aTestSuite = (TestSuite) aTest;
                suite2.addTest(filterOutTests(aTestSuite, testURIs));
            } else if (aTest instanceof BigdataSPARQLUpdateConformanceTest) {
                final BigdataSPARQLUpdateConformanceTest test = 
                        (BigdataSPARQLUpdateConformanceTest) aTest;
                if (!testURIs.contains(test.testURI)) {
                    suite2.addTest(test);
                }
            }

        }
        return suite2;
       
    }
 
Example 5
Source File: JUnit38ClassRunner.java    From android-test with Apache License 2.0 6 votes vote down vote up
static Description makeDescription(Test test) {
  if (test instanceof TestCase) {
    TestCase tc = (TestCase) test;
    return Description.createTestDescription(tc.getClass(), tc.getName(), getAnnotations(tc));
  } else if (test instanceof TestSuite) {
    TestSuite ts = (TestSuite) test;
    String name = ts.getName() == null ? createSuiteDescription(ts) : ts.getName();
    Description description = Description.createSuiteDescription(name);
    int n = ts.testCount();
    for (int i = 0; i < n; i++) {
      Description made = makeDescription(ts.testAt(i));
      description.addChild(made);
    }
    return description;
  } else if (test instanceof Describable) {
    Describable adapter = (Describable) test;
    return adapter.getDescription();
  } else if (test instanceof TestDecorator) {
    TestDecorator decorator = (TestDecorator) test;
    return makeDescription(decorator.getTest());
  } else {
    // This is the best we can do in this case
    return Description.createSuiteDescription(test.getClass());
  }
}
 
Example 6
Source File: ProxySuiteHelper.java    From database with GNU General Public License v2.0 5 votes vote down vote up
private static Test cloneSuite(final Test delegate, final TestSuite suite) {
	final TestSuite rslt =  new CloningTestSuite(delegate,suite.getName());
	final Enumeration<Test> enumerate = suite.tests();
	while( enumerate.hasMoreElements() ) {
		rslt.addTest(enumerate.nextElement());
	}
	return rslt;
}
 
Example 7
Source File: TestRunContainer.java    From scipio-erp with Apache License 2.0 4 votes vote down vote up
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;
}