public void endTestSuite()

in src/main/org/apache/ant/antunit/listener/FailureAntUnitListener.java [91:132]


    public void endTestSuite(Project testProject, String buildFile) {
        StringBuilder sb = new StringBuilder();
        // <project> and antunit-target for direct run
        sb.append("<project default=\"antunit\" xmlns:au=\"antlib:org.apache.ant.antunit\">");
        sb.append(BR);
        sb.append(BR);
        sb.append("  <target name=\"antunit\">").append(BR);
        sb.append("    <au:antunit>").append(BR);
        sb.append("      <au:plainlistener/>").append(BR);
        sb.append("      <file file=\"${ant.file}\"/>").append(BR);
        sb.append("    </au:antunit>").append(BR);
        sb.append("  </target>").append(BR);
        sb.append(BR);
        sb.append(BR);

        // one target for each failed test
        int testNumber = 0;
        NumberFormat f = NumberFormat.getIntegerInstance();
        for (Iterator<TestInfos> it = failedTests.iterator(); it.hasNext();) {
            sb.append("  <target name=\"test");
            sb.append(f.format(testNumber++));
            sb.append("\">").append(BR);
            TestInfos testInfos = it.next();
            sb.append(testInfos);
            sb.append("  </target>").append(BR);
            sb.append(BR);
        }

        // close the <project>
        sb.append("</project>").append(BR);

        // write the whole file
        try {
            FileOutputStream fos = new FileOutputStream(failureBuildfile);
            fos.write(sb.toString().getBytes());
            FileUtils.close(fos);
        } catch (FileNotFoundException e) {
            throw new BuildException(e);
        } catch (IOException e) {
            throw new BuildException(e);
        }
    }