In the previous blog post I described how to JUnit test your
Selenium tests. Once you have this set up, you can use Ant to run this tests
and create a report about the results.
Since there are standard targets for JUnit and JUnitReport in Ant, the Ant file is pretty clean. We start
with setting up our environment, including a clean target. The tool I use to display the XML on my blog makes it a bit messy, but you get the idea:
We set up
the output directories, the reports will come in the reports directory. In the
Lib directory, we put the selenium standalone jar file that is used to run the
Selenium test in JUnit. As well as the JUnit jar to run the JUnit test itself.
After that
there are two targets, prepare and compile:
In the
prepare we set up the structure and create the directories that we need. In the
compile we look for all the java sources in the src directory and compile them
to the classes directory. Now all that is left is a target to run the JUnit and
create the reports:
I choose
not to split those two target, since I never want to run a test without
creating the reports or vice versa. The JUnit runs all the tests that are in
the classes dir, where the compile target puts his output, he runs the JUnit
test using the classpath that is set up in the environment and puts this in the
output directory.
After this
the JUnitReport tasks picks up the reports from the output directory and
creates a HTML structure off all the tests that are ran. This is how the
index.html looks:
You see an
overview of the tests, the failures and erros, all clickable to drill down for
more information.
If you like
you can browse through the packages & classes.