Fun with Ant FileScanners… or FIT Test harness
The Ant File Scanners can be a useful tool for Java developers, and can be called programmatically quite easily. I have done it a couple of times for writing simple development tools. I don’t bother writing ant tasks, but just have programs that depend on the ant jar being available.
I have just started using FIT for my acceptance tests. I am waiting for tools that hook into fit to be released, but in the meantime wanted an easy way of running all my fit tests at once.
The org.apache.tools.ant.DirectoryScanner class that implements the org.apache.tools.ant.FileScanner interface is great for doing things like this. It lets you specify:
a base directory void setBasedir(String s);
an array of includes patterns void setIncludes(String[] strings);
an array of excludes patterns void setExcludes(String[] strings);
After doing this you can .run the scanner void scan();, and see the results:
String[] getIncludedFiles();
I have put the source code for my FIT test runner here:
FitTestRunner.java
ps - I would have loved to have linked to the ant java doc for their classes, but this was not possible at the time of publishing this — the link on ant.apache.org was bad.
September 14th, 2004 at 8:34 am
Hmmm… I really should get around to committing the Agilifier stuff!
I’ll do it tonight - ready or not!