Hibernate.orgCommunity Documentation
This chapter explains how to execute and debug a test suite built using the JBoss Test Harness.
The test suite runner project is the magic that makes everything come together and allows you to execute the test suite. If you fully understand how the JBoss Test Harness functions, and have a good grasp on Maven 2, then it's not to difficult to understand how the test suite runner project works. Regardless of your background, this guide covers what you need to know to get up and running by studying the test suite runner used to run the Bean Validation TCK against the Bean Validation RI, Hibernate Validator.
The TCK runner for the Hibernate Validator can be found in the
hibernate-validator-tck-runner
directory in the
Hibernate Validator checkout. The dependencies of the TCK runner project
for Hibernate Validator are listed in Table 10.1, “Bean Validation TCK Runner Dependencies”.
Table 10.1. Bean Validation TCK Runner Dependencies
Group ID | Artifact ID | Version |
---|---|---|
javax.validation | validation-api | 1.0.0.GA |
org.hibernate | hibernate-validator | 4.2.0.Final |
org.hibernate.jsr303.tck | jsr303-tck | 1.0.8.GA |
org.hibernate.javax.persistence | hibernate-jpa-2.0-api | 1.0.1.Final |
org.sl4j | slf4j-api, slf4j-simple | 1.6.1 |
org.testng | testng (classifier: jdk15) | 5.8 |
org.jboss.jbossas.as7-cdi-tck | jbossas-container | 1.0.0.Alpha1 |
You can find all of these artifacts in the JBoss Maven repository.
You should substituate the hibernate-validator artifact from Table 10.1, “Bean Validation TCK Runner Dependencies” with your own artifact. You'll also
need to replace the jbossas-container artifact if you are not testing your
implementation on JBoss AS. The jbossas-container artifact contains
implementations of the Containers
SPI for the JBoss
Test Harness for JBoss AS 7.
When running the test suite in the in-container mode, the tests will run against libraries installed into the container.
The TCK is executed using the Maven TestNG plugin. Maven 2 profiles
are used to control the properties that are set at the time of the
execution. For instance, the incontainer
profile
enables integration tests and disables standalone mode, changing the
default settings.
As you have learned, when the test suite is executing using in-container mode, each test class is packaged as a deployable artifact and deployed to the container. The test is then executed within the context of the deployed application. This leaves room for errors in packaging. When investigating a test failure, it's helpful to be able to inspect the artifact after it is generated. The JBoss Test Harness can accommodate this type of inspection by "dumping" the generated artifact to disk.
If you want to write the artifacts to disk, and avoid executing the
test suite, you can simply execute the main method of the class
org.jboss.testharness.api.TCK
. For example you could
use a Maven profile that is activated when the
dumpArtifacts
command line property is defined:
mvn test-compile -DdumpArtifacts
The output directory where the artifacts are written is defined by
the property
org.jboss.testharness.outputDirectory
.
Once the artifact is written to disk, you have an option of manually
deploying it to the container. You can execute the tests in the artfact by
requesting the context path of the application in the browser. If you want
to execute an individual test method, specify the method name in the
methodName
request parameter (e.g.,
?methodName=testMethodName).
Copyright © 2009 - 2011 Red Hat, Inc.