void addTests(Class<? extends TestCase> clazz, String... names) throws Exception { Constructor cnt = clazz.getConstructor(String.class); for (String n : names) { Test t = (Test)cnt.newInstance(n); addTest(t); } }
/** * adds a test suite to this test suite */ @Override public void addTestSuite(Class<? extends TestCase> testClass) { if (ignoreRandomFailures() && testClass.isAnnotationPresent(RandomlyFails.class)) { System.err.println("Skipping " + testClass.getName()); return; } NbTest t = new NbTestSuite(testClass); t.setFilter(fFilter); addTest(t); }
public static TestSuite suite(Class<?> clazz, String filePattern) { NbTestSuite result = new NbTestSuite(); Pattern patt = Pattern.compile(filePattern); for (String test : listTests(clazz)) { if (!patt.matcher(test).matches()) { continue; } //TODO: URL testURL = clazz.getClassLoader().getResource(test); assertNotNull(testURL); FileObject testFO = URLMapper.findFileObject(testURL); assertNotNull(testFO); String hint = test.substring(0, test.length() - ".test".length()) + ".hint"; URL hintURL = clazz.getClassLoader().getResource(hint); assertNotNull(hintURL); FileObject hintFO = URLMapper.findFileObject(hintURL); assertNotNull(hintFO); try { for (TestCase tc : TestParser.parse(testFO.asText("UTF-8"))) { result.addTest(new DeclarativeHintsTestBase(hintFO, testFO, tc)); } } catch (IOException ex) { throw new IllegalStateException(ex); } } return result; }