Hey folks,

Marian Petras just integrated the new JUnit test result viewer in the daily dev builds. Check it out, it's preeeeeetttttttyyyyyyyyy. And it makes your test results easier to read.

Still not pretty enough? Maybe you've gotta send those test results out to the whole team? No problem, you can use junitreport. As reported by Marian on some thread (don't remember where), you just copy your -init-macrodef-junit target from build-impl.xml to build.xml, then add the following lines in bold:

<target name="-init-macrodef-junit">
    <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/2">
        <attribute name="includes" default="**/*Test.java"/>
        <sequential>
            <junit showoutput="true" fork="true" dir="${basedir}" failureproperty="tests.failed" errorproperty="tests.failed">
                <batchtest todir="${build.test.results.dir}">
                    <fileset dir="${test.src.dir}" includes="@{includes}"/>
                </batchtest>
                <classpath>
                    <path path="${run.test.classpath}"/>
                </classpath>
                <syspropertyset>
                    <propertyref prefix="test-sys-prop."/>
                    <mapper type="glob" from="test-sys-prop.*" to="*"/>
                </syspropertyset>
                <formatter usefile="false" type="brief"/>
                <formatter usefile="true" type="xml"/>
            </junit>
            <junitreport todir="${build.test.results.dir}">
                <fileset dir="${build.test.results.dir}">
                    <include name="TEST-*.xml"/>
                </fileset>
                <report todir="${build.test.results.dir}/html"/>
            </junitreport> 
        </sequential>
    </macrodef>
</target>

When you test your project (Alt-F6), the IDE generates the tests to to the following build/test/results folder.

And look how pretty that looks.

Fabulous, darling!

Comments:

Rather than adding the both those extra bits to the -init-macrodef-junit target, I prefer to add just the additional formatter and then override the existing (empty) test-report target to do the junitreport task. Doesn't really make any difference in the end, but it feels more correct to me (after all, why else would that target be there?)

You might also wish to add a nbbrowse task to the -test-browse target and have it automatically open up the test results in whatever web browser you've configured Netbeans to use. Frankly, I'm surprised the project configuration doesn't do any of this by default.

Posted by Andy Stevens on August 15, 2005 at 01:06 AM CEST #

Of course, since you can't turn the panel off, it shows up when you don't have any JUnit tests defined, every single bloody time you compile anything or clean anything or run any build-related tasks. And since turning it completely off turns off a bunch of other functionality which you probably want to keep turned on, you're stuck with just having to close the pane over and over and over and over again, which added clicks really add up and hack off developers. But it is really nifty and pretty, and were you to actually define and use JUnit tests, it would probably be a great little bit of functionality.

Posted by DougN on August 17, 2005 at 10:30 PM CEST #

Hi,

It worked well....Thank u.

Thanks,
Sowmya

Posted by 66.201.58.101 on September 10, 2008 at 02:57 AM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed

This blog copyright 2009 by johnc