/** * 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); }
/** Factory method to create a special execution suite that not only * executes the tests but also measures the times each execution took. * It then compares the times and fails if the difference is too big. * Test tests can be executed more times to eliminate the effect * of GC and hotspot compiler. * * @param clazz the class to create tests for (from methods starting with test) * @param slowness this must be true: slowness * min < max * @param repeat number of times to repeat the test */ public static NbTestSuite speedSuite (Class<? extends TestCase> clazz, int slowness, int repeat) { if (ignoreRandomFailures()) { System.err.println("Skipping " + clazz.getName()); return new NbTestSuite("skipping"); } return new SpeedSuite (clazz, repeat, slowness, SpeedSuite.CONSTANT); }
/** Factory method to create a special execution suite that not only * executes the tests but also measures the times each execution took. * It then compares the times devided by the size of query * and fails if the difference is too big. * Test tests can be executed more times to eliminate the effect * of GC and hotspot compiler. * * @param clazz the class to create tests for (from methods starting with test) * @param slowness this must be true: slowness * min < max * @param repeat number of times to repeat the test */ public static NbTestSuite linearSpeedSuite (Class<? extends TestCase> clazz, int slowness, int repeat) { if (ignoreRandomFailures()) { System.err.println("Skipping " + clazz.getName()); return new NbTestSuite("skipping"); } return new SpeedSuite (clazz, repeat, slowness, SpeedSuite.LINEAR); }
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; }
testLoader.loadClass("junit.framework.Test"); testLoader.loadClass("org.netbeans.junit.NbTestSuite"); NbTestSuite toRun = new NbTestSuite();