/** * Return all <tt>JUnitTest</tt> instances obtain by applying the fileset rules. * @return an enumeration of all elements of this batchtest that are * a <tt>JUnitTest</tt> instance. */ public Enumeration<JUnitTest> elements() { return Collections.enumeration(Arrays.asList(createAllJUnitTest())); }
/** * Merge all individual tests from the batchtest with all individual tests * and return an enumeration over all <tt>JUnitTest</tt>. * * @return enumeration over individual tests * @since Ant 1.3 */ protected Enumeration<JUnitTest> getIndividualTests() { return Collections.enumeration(Stream.concat(batchTests.stream() .flatMap(b -> Collections.list(b.elements()).stream()), tests.stream()) .collect(Collectors.toList())); }
/** * Create all <tt>JUnitTest</tt>s based on the filesets. Each instance * is configured to match this instance properties. * @return the array of all <tt>JUnitTest</tt>s that belongs to this batch. */ private JUnitTest[] createAllJUnitTest() { return Stream.of(getFilenames()).map(BatchTest::javaToClass) .map(this::createJUnitTest).toArray(JUnitTest[]::new); }
/** * Create a <tt>JUnitTest</tt> that has the same property as this * <tt>BatchTest</tt> instance. * @param classname the name of the class that should be run as a * <tt>JUnitTest</tt>. It must be a fully qualified name. * @return the <tt>JUnitTest</tt> over the given classname. */ private JUnitTest createJUnitTest(String classname) { JUnitTest test = new JUnitTest(); test.setName(classname); test.setHaltonerror(this.haltOnError); test.setHaltonfailure(this.haltOnFail); test.setFiltertrace(this.filtertrace); test.setFork(this.fork); test.setIf(getIfCondition()); test.setUnless(getUnlessCondition()); test.setTodir(this.destDir); test.setFailureProperty(failureProperty); test.setErrorProperty(errorProperty); test.setSkipNonTests(isSkipNonTests()); this.formatters.forEach(test::addFormatter); return test; }
/** * Adds a set of tests based on pattern matching. * * @return a new instance of a batch test. * @see BatchTest * @since Ant 1.2 */ public BatchTest createBatchTest() { final BatchTest test = new BatchTest(getProject()); batchTests.add(test); preConfigure(test); return test; }
/** * Add a new fileset instance to this batchtest. Whatever the fileset is, * only filename that are <tt>.java</tt> or <tt>.class</tt> will be * considered as 'candidates'. * @param fs the new fileset containing the rules to get the testcases. */ public void addFileSet(FileSet fs) { add(fs); // this one is here because the changes to support ResourceCollections // have broken Magic's JUnitTestTask. // // The task adds a FileSet to a BatchTest instance using the // Java API and without telling the FileSet about its project // instance. The original code would pass in project on the // call to getDirectoryScanner - which is now hidden deep into // Resources.iterator() and not reachable. if (fs.getProject() == null) { fs.setProject(project); } }
forkPerTest)); } else { /* forkMode.getValue().equals(ForkMode.PER_BATCH) */ batchTests.stream().map(b -> executeOrQueue(b.elements(), false)) .forEach(testLists::addAll); testLists.addAll(
/** * Convenient method to merge the <tt>JUnitTest</tt>s of this batchtest * to a <tt>Vector</tt>. * @param v the vector to which should be added all individual tests of this * batch test. */ void addTestsTo(Vector<? super JUnitTest> v) { JUnitTest[] tests = createAllJUnitTest(); v.ensureCapacity(v.size() + tests.length); for (JUnitTest test : tests) { v.addElement(test); } }