SeamFramework.orgCommunity Documentation
This chapter lays out how to configure the TCK Harness by specifying the SPI implementation classes, defining the target container connection information, and various other switches. You then learn how to setup a TCK runner project that executes the the TCK test suite, putting these settings into practice. Finally, a detailed account of how the JBoss Test Harness negotiates the execution of the tests in the container is given.
This chapter does not discuss in detail how to use the TCK in standalone mode. The JBoss Test Harness guide provides more on running in standalone mode.
The JBoss Test Harness allows the test suite to be launched in a pluggable fashion. In order to execute the TCK, the JBoss Test Harness must be configured by specifying implementations of the test launcher and container APIs.
System properties and/or the resource
META-INF/jboss-test-harness.properties
,
a Java properties file, are used to configure the JBoss Test Harness.
You can read more about configuring the JBoss Test Harness in
Section 10.1, “JBoss Test Harness Properties”.
You should set the following properties:
Table 4.1. Required JBoss Test Harness Configuration Properties
Property = Required/Example Value | Description |
---|---|
org.jboss.testharness.libraryDirectory=/path/to/extra/libraries
| Directory containing extra JARs you want placed in artifact library directory such as the porting package implementation. |
org.jboss.testharness.standalone=false
| You must run the tests in-container to pass the TCK |
org.jboss.testharness.runIntegrationTests=true
| You must run the integration tests to pass the TCK |
org.jboss.testharness.spi.Containers=com.acme.AcmeContainer
| The container implementation for deploying and executing in-container tests. See Note |
org.jboss.testharness.api.TestLauncher=org.jboss.testharness.impl.runner.servlet.ServletTestLauncher
|
You should use the
ServletTestLauncher
for Java EE 6 and Java EE 6 Web Profile.
|
To run the full TCK you must additionally implement
org.jboss.testharness.spi.Containers
,
which handles deploying the test artifact to the container. An
implementations of this API is already available for JBoss AS 5.1.
Therefore, you only need to implement this part of the porting package
if you wish to use another container.
The CDI TCK relies on an implementation of the porting package to function. The porting package can be divided into two parts. The first part is comprised of extensions to the CDI SPIs to allow testing of a container. The second part must implement the JBoss Test Harness artifact deployment APIs for deploying artifacts to the Java EE container.
As mentioned earlier, there are times when the tests need to tap directly into the CDI implementation to manipulate behavior or verify results. The porting package includes a set of SPIs that provide the TCK this level of access without tying the tests to a given implementation.
The four SPI classes in the CDI TCK are as follows:
org.jboss.jsr299.tck.spi.Beans
org.jboss.jsr299.tck.spi.Contexts
org.jboss.jsr299.tck.spi.EL
org.jboss.jsr299.tck.spi.Managers
Please consult the JavaDoc for these interfaces for the implementation requirements.
The JBoss Test Harness is built atop TestNG, and it's TestNG that is responsible for selecting the tests to execute, the order of execution, and reporting the results. Detailed TestNG documentation can be found at testng.org.
The
tck-tests.xml
artifact provided in the TCK distribution must be run by TestNG 5.9
(described by the TestNG documenation as "with a
testng.xml
file") unmodified for an implementation to pass the TCK. This file also
allows tests to be excluded from a run:
<suite name="JSR-299 TCK" verbose="2"> <test name="JSR-299 TCK"> ... <classes> <class name="org.jboss.jsr299.tck.tests.context.application.ApplicationContextTest"> <methods> <exclude name="testApplicationScopeActiveDuringServiceMethod"/> </methods> </class> </classes> ... </test> </suite>
TestNG provides extensive reporting information. Depending on the build tool or IDE you use, the reporting will take a different format. Please consult the TestNG documentation and the tool documentation for more information.
It's beyond the scope of this guide to describe in how to set up your build environment to run the TCK. The JBoss Test Harness guide describes how Weld uses Maven 2 to execute the CDI TCK. See Section 11.1, “Building a test suite runner using Maven 2”. The TestNG documentation provides extensive information on launching TestNG using the Java, Ant, Eclipse or IntellJ IDEA.