The integration with Ant allows the acceptance tests to be run as part of the overall build. In projects where a build and deploy is complex and requires integration with application servers or other complexities, having the power of Ant to handle the steps and run the tests together is an important benefit.
The basic runner iterates over a FileSet of test documents in the specified input directory, and leaves the results in an output directory
The choice to subclass WikiRunner rather than the basic FileRunner was deliberate. In playing with various documents it became clear that having the ability to segregate fixture content from non-fixture content was a desirable feature. If anyone has a different story, this choice could be made configurable.SourceForge repository.
Digging deeper into Ant has given me some insight about issues with the current tasks and ways to make it more useful in the scenarios typical of Ant usage. To this point the quest has taken me far into the world of Java classloader voodoo.
It turns out that the way Fixture was loading classes was not compatible with the advanced classloader behavior of Ant.
On line 69 of Fixture.java, the code is:
Fixture fixture = (Fixture)(Class.forName(heading.text()).newInstance());The javadoc for Class.forName() says that this attempts to load the class in the same loader as the current class. However, in Ant, this will not work with the AntFit task because the task and FIT classes are loaded by Ant's root classloader, but the classes under test are loaded by a different classloader, by design. What this means is that when Fixture calls Class.forName() Java will try to load the class in the same classloader that loaded Fixture, but of course those classes won't be there, so you get a ClassNotFoundException.
There is a similar line of code in ActionFixture.
There is a change that will solve the problem for Ant and still work for the general use of FIT outside of Ant. Change the line to load the class with the classloader associated with the current thread, which will be the one that loads the classes of the application being tested. The new line is much uglier, but basically the same:
Fixture fixture = (Fixture)Thread.currentThread().getContextClassLoader().loadClass(heading.text()).newInstance();http://java.sun.com/j2se ... ass.html#forName(java.lang.String)
|Last edited April 7, 2005
Return to WelcomeVisitors