Information Technology Reference
In-Depth Information
would have a directory structure which maps to the system tests' pack-
age names (which usually map to the corresponding class under the
tests' packages), as shown in Listing 6-9.
LISTING 6-9
Sample Directory Structure of the system Folder
test/
system/
test/
com/
acme/
stock/
LogInTest.java
AccountTest.java
Now that the tests are segregated into separate directories, your
chosen build system needs an update. In the case of Ant, running cate-
gorized tests becomes a matter of defining targets that use the
batchtest element found in Ant's JUnit task, which is displayed in
Listing 6-10.
LISTING 6-10
The JUnit Task's batchtest Element
<batchtest todir="${testreportdir}">
<fileset dir="test/unit">
<include name="**/*Test.*"/>
</fileset>
</batchtest>
The naming pattern referenced in the include element is
generic—it's the directory referenced in the dir attribute of fileset
that specifies what tests to run, which in this case are the unit tests.
Don't forget that you can also automate functional tests, such as
those defined with Selenium; however, these tests will follow a differ-
ent execution paradigm with additional test runners that can be easily
segregated, for example, into unique Ant tasks. By defining a common
manner for categorizing tests, such as through annotations or naming
patterns, you are all set to instruct your CI system to run each category
when appropriate, and your build times are completely manageable.
This means that tests can be run at regular intervals instead of being
abandoned when they take too long to execute.
Search WWH ::




Custom Search