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

The following examples show how to use junit.framework.TestSuite#testCount() . 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: 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 2
Source File: TestTreeItem.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public ObservableList<TreeItem<Test>> getChildren() {
    ObservableList<TreeItem<Test>> children = super.getChildren();
    if (!children.isEmpty()) {
        if (testRunner.showFailures()) {
            List<TreeItem<Test>> failures = children.stream().filter(new Predicate<TreeItem<Test>>() {
                @Override
                public boolean test(TreeItem<Test> t) {
                    return ((TestTreeItem) t).getState() == State.ERROR || ((TestTreeItem) t).getState() == State.FAILURE;
                }
            }).collect(Collectors.toList());
            children.setAll(failures);
        } else {
            if (children.containsAll(allChildren)) {
                return children;
            }
            children.setAll(allChildren);
        }
    } else {
        if (test instanceof TestSuite) {
            TestSuite suite = (TestSuite) test;
            int countTestCases = suite.testCount();
            for (int i = 0; i < countTestCases; i++) {
                children.add(new TestTreeItem(suite.testAt(i), testRunner));
            }
            allChildren.setAll(children);
        }
    }
    return children;
}
 
Example 3
Source File: MemoryValidator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static TestSuite wrap(TestSuite t) {
    TestSuite result = new TestSuite();
    
    for (int cntr = 0; cntr < t.testCount(); cntr++) {
        result.addTest(wrap(t.testAt(cntr)));
    }
    
    return result;
}
 
Example 4
Source File: BSFTest.java    From commons-bsf with Apache License 2.0 5 votes vote down vote up
public static void main(String args[]) {
    TestRunner runner = new TestRunner();
    TestSuite suite = (TestSuite) suite();
    TestResult results;

    for (int i = 0; i < suite.testCount(); i++) {
        System.out.print(testNames[i]);
        results = runner.doRun(suite.testAt(i), false);
        System.out.println("Results: " + results.runCount() + 
                           " tests run, " + results.failureCount() +
                           " failures, " + results.errorCount() +
                           " errors.");
        System.out.print("\n----------------------------------------\n");
    }
}
 
Example 5
Source File: SHACLManifestTestSuiteFactory.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Creates a new {@link TestSuite} for executiong of {@link AbstractSHACLTest} s.
 *
 * @param factory                   a factory class that creates each individual test case.
 * @param officialWorkingGroupTests indicates whether to use the official W3C working group tests, or Sesame's own
 *                                  set of tests.
 * @param approvedTestsOnly         if <code>true</code>, use working group-approved tests only. Has no influence
 *                                  when officialWorkingGroup tests is set to <code>false</code>.
 * @param useRemoteTests            if set to <code>true</code>, use manifests and tests located at
 *                                  <code>http://www.w3.org/2009/sparql/docs/tests/data-sparql11/</code> , instead
 *                                  of local copies.
 * @param excludedSubdirs           an (optionally empty) list of subdirectories to exclude from testing. If
 *                                  specified, test cases in one of the supplied subdirs will not be executed. If
 *                                  left empty, all tests will be executed.
 * @return a TestSuite.
 * @throws Exception
 */
public TestSuite createTestSuite(TestFactory factory, boolean officialWorkingGroupTests, boolean approvedTestsOnly,
		boolean useRemoteTests, String... excludedSubdirs) throws Exception {
	final String manifest = getManifestFile(officialWorkingGroupTests, useRemoteTests);

	TestSuite suite = new TestSuite(factory.getName()) {

		@Override
		public void run(TestResult result) {
			try {
				super.run(result);
			} finally {
				if (tmpDir != null) {
					try {
						FileUtil.deleteDir(tmpDir);
					} catch (IOException e) {
						System.err.println(
								"Unable to clean up temporary directory '" + tmpDir + "': " + e.getMessage());
					}
				}
			}
		}
	};

	Map<String, TestSuite> tests = new LinkedHashMap<>();
	ValueFactory vf = SimpleValueFactory.getInstance();
	Model manifests = new LinkedHashModel();
	readTurtle(manifests, new URL(manifest), manifest, excludedSubdirs);
	for (Value included : manifests.filter(null, vf.createIRI(MF_INCLUDE), null).objects()) {
		String subManifestFile = included.stringValue();
		boolean hasEntries = manifests.contains((IRI) included, vf.createIRI(MF_ENTRIES), null);
		if (hasEntries && includeSubManifest(subManifestFile, excludedSubdirs)) {
			TestSuite suiteEntry = createSuiteEntry(subManifestFile, factory, approvedTestsOnly);
			if (tests.containsKey(suiteEntry.getName())) {
				for (int i = 0, n = suiteEntry.testCount(); i < n; i++) {
					tests.get(suiteEntry.getName()).addTest(suiteEntry.testAt(i));
				}
			} else {
				tests.put(suiteEntry.getName(), suiteEntry);
			}
		}
	}
	for (TestSuite testSuiets : tests.values()) {
		suite.addTest(testSuiets);
	}

	logger.info("Created aggregated test suite with " + suite.countTestCases() + " test cases.");
	return suite;
}