SeamFramework.orgCommunity Documentation

Technology Compatibility Kit Reference Guide for JSR 346: Contexts and Dependency Injection for Java EE 1.1

Specification Lead: Red Hat Inc.


Preface
1. Who Should Use This Book
2. Before You Read This Book
3. How This Book Is Organized
I. Getting Acquainted with the TCK
1. Introduction (CDI TCK)
1.1. TCK Primer
1.2. Compatibility Testing
1.2.1. Why Compatibility Is Important
1.3. About the CDI TCK
1.3.1. CDI TCK Specifications and Requirements
1.3.2. CDI TCK Components
2. Appeals Process
2.1. Who can make challenges to the TCK?
2.2. What challenges to the TCK may be submitted?
2.3. How these challenges are submitted?
2.4. How and by whom challenges are addressed?
2.5. How accepted challenges to the TCK are managed?
3. Installation
3.1. Obtaining the Software
3.2. The TCK Environment
3.3. Eclipse Plugins
3.3.1. TestNG Plugin
3.3.2. Maven Plugin (m2e)
4. Configuration
4.1. TCK Properties
4.2. Arquillian settings
4.3. The Porting Package
4.4. Using the CDI TCK with the Java EE Web Profile
4.5. Configuring TestNG to execute the TCK
4.6. Configuring your build environment to execute the TCK
4.7. Configuring your application server to execute the TCK
5. Reporting
5.1. CDI TCK Coverage Metrics
5.2. CDI TCK Coverage Report
5.2.1. CDK TCK Assertions
5.2.2. Producing the Coverage Report
5.2.3. TestNG Reports
II. Executing and Debugging Tests
6. Running the Signature Test
6.1. Obtaining the sigtest tool
6.2. Running the signature test
6.3. Forcing a signature test failure
7. Executing the Test Suite
7.1. The Test Suite Runner
7.2. Running the Tests In Standalone Mode
7.3. Running the Tests In the Container
7.4. Dumping the Test Archives
8. Running Tests in Eclipse
8.1. Leveraging Eclipse's plugin ecosystem
8.2. Readying the Eclipse workspace
8.3. Running a test in standalone mode
8.4. Running integration tests
9. Debugging Tests in Eclipse
9.1. Debugging a standalone test
9.2. Debugging an integration test
9.2.1. Attaching the IDE debugger to the container
9.2.2. Launching the test in the debugger

This guide describes how to download, install, configure, and run the Technology Compatibility Kit (TCK) used to verify the compatibility of an implementation of the JSR 346: Context and Dependency Injection for Java EE (CDI) 1.1 specification.

The CDI TCK is built atop TestNG framework and Arquillian platform. The CDI TCK uses the Arquillian version 1.0.3.Final to execute the test suite.

The CDI TCK is provided under the Apache Public License 2.0.

Before reading this guide, you should familiarize yourself with the Java EE programming model, specifically the Enterprise JavaBeans (EJB) 3.1 and the Contexts and Dependency Injection for Java EE 1.1 specifications. A good resource for the Java EE programming model is the JCP web site.

The CDI TCK is based on the Context and Dependency Injection for Java EE 1.1 technology specification (JSR 346). Information about the specification, including links to the specification documents, can be found on the JSR 346 JCP page.

Before running the tests in the CDI TCK, read and become familiar with the Arquillian testing platform. A good starting point could be a series of Arquillian Guides.

If you are running the CDI TCK for the first time, read Chapter 1, Introduction (CDI TCK) completely for the necessary background information about the TCK. Once you have reviewed that material, perform the steps outlined in the remaining chapters.

  • Chapter 1, Introduction (CDI TCK) gives an overview of the principles that apply generally to all Technology Compatibility Kits (TCKs), outlines the appeals process and describes the CDI TCK architecture and components. It also includes a broad overview of how the TCK is executed and lists the platforms on which the TCK has been tested and verified.

  • Chapter 2, Appeals Process explains the process to be followed by an implementor should they wish to challenge any test in the TCK.

  • Chapter 3, Installation explains where to obtain the required software for the CDI TCK and how to install it. It covers both the primary TCK components as well as tools useful for troubleshooting tests.

  • Chapter 4, Configuration details the configuration of the JBoss Test Harness, how to create a TCK runner for the TCK test suite and the mechanics of how an in-container test is conducted.

  • Chapter 5, Reporting explains the test reports that are generated by the TCK test suite and introduces the TCK audit report as a tool for measuring the completeness of the TCK in testing the JSR 346 specification and in understanding how testcases relate to the specification.

  • Chapter 7, Executing the Test Suite documents how the TCK test suite is executed. It covers both modes supported by the TCK, standalone and in-container, and shows how to dump the generated test artifacts to disk.

  • Chapter 8, Running Tests in Eclipse shows how to run individual tests in Eclipse and advises the best way to setup your Eclipse workspace for running the tests.

  • Chapter 9, Debugging Tests in Eclipse builds on Chapter 8, Running Tests in Eclipse by detailing how to debug individual tests in Eclipse.

The CDI TCK must be used to ensure that your implementation conforms to the CDI specification. This part introduces the TCK, gives some background about its purpose, states the requirements for passing the TCK and outlines the appeals process.

In this part you will learn where to obtain the CDI TCK and supporting software. You are then presented with recommendations of how to organize and configure the software so that you are ready to execute the TCK.

Finally, it discusses the reporting provided by the TCK.

This chapter explains the purpose of a TCK and identifies the foundation elements of the CDI TCK.

A TCK, or Technology Compatibility Kit, is one of the three required pieces for any JSR (the other two being the specification document and the reference implementation). The TCK is a set of tools and tests to verify that an implementation of the technology conforms to the specification. The tests are the primary component, but the tools serve an equally critical role of providing a framework and/or set of SPIs for executing the tests.

The tests in the TCK are derived from assertions in the written specification document. The assertions are itemized in an XML document, where they each get assigned a unique identifier, and materialize as a suite of automated tests that collectively validate whether an implementation complies with the aforementioned assertions, and in turn the specification. For a particular implementation to be certified, all of the required tests must pass (i.e., the provided test suite must be run unmodified).

A TCK is entirely implementation agnostic. Ideally, it should validate assertions by consulting the specification's public API. However, when the information returned by the public API is not low-level enough to validate the assertion, the implementation must be consulted directly. In this case, the TCK provides an independent API as part of a porting package that enables this transparency. The porting package must be implemented for each CDI implementation. Section 1.3.2, “CDI TCK Components” introduces the porting package and Section 4.3, “The Porting Package” covers the requirements for implementing it.

Note

Oracle Corporation will implement the porting package for the CDI RI and test the CDI RI on the Java EE Reference Implementation.

The goal of any specification is to eliminate portability problems so long as the program which uses the implementation also conforms to the rules laid out in the specification.

Executing the TCK is a form of compatibility testing. It's important to understand that compatibility testing is distinctly different from product testing. The TCK is not concerned with robustness, performance or ease of use, and therefore cannot vouch for how well an implementation meets these criteria. What a TCK can do is to ensure the exactness of an implementation as it relates to the specification.

Compatibility testing of any feature relies on both a complete specification and a complete reference implementation. The reference implementation demonstrates how each test can be passed and provides additional context to the implementor during development for the corresponding assertion.

The CDI TCK is designed as a portable, configurable and automated test suite for verifying the compatibility of an implementation of the JSR 346: Contexts and Dependency Injection for Java EE 1.1 specification. The test suite is built atop TestNG framework and Arquillian platform.

Each test class in the suite acts as a deployable unit. The deployable units, or artifacts, can be either a WAR or an EAR.

This section lists the applicable requirements and specifications for the CDI TCK.

While the CDI TCK is rigorous about enforcing an implementation's conformance to the JSR 346 specification, it's reasonable to assume that an implementor may discover new and/or better ways to validate the assertions. This chapter covers the appeals process, defined by the Specification Lead, Red Hat Middleware LLC., which allows implementors of the JSR 346 specification to challenge one or more tests defined by the CDI TCK.

The appeals process identifies who can make challenges to the TCK, what challenges to the TCK may be submitted, how these challenges are submitted, how and by whom challenges are addressed and how accepted challenges to the TCK are managed.

Following the recent adoption of transparency in the JCP, implementors are encouraged to make their appeals public, which this process facilitates. The JCP community should recognize that issue reports are a central aspect of any good software and it's only natural to point out shortcomings and strive to make improvements. Despite this good faith, not all implementors will be comfortable with a public appeals process. Instructions about how to make a private appeal are therefore provided.

To submit a challenge, a new issue should be created in the CDI TCK project of the JBoss JIRA using the Issue Type: Bug. The appellant should complete the Summary, Component (TCK Appeal), Environment and Description Field only. Any communication regarding the issue should be pursed in the comments of the filed issue for accurate record.

To submit an issue in the JBoss JIRA, you must have a (free) JBoss.org member account. You can create a member account using the on-line registration.

If you wish to make a private challenge, you should follow the above procedure, setting the Security Level to Private. Only the issue reporter, TCK Project Lead and designates will be able to view the issue.

This chapter explains how to obtain the TCK and supporting software and provides recommendations for how to install/extract it on your system.

You can obtain a release of the CDI TCK project from the download page on Seam Framework website. The release stream for JSR 346 is named 1.1.x. The CDI TCK is distributed as a ZIP file, which contains the TCK artifacts (the test suite binary and source, porting package API binary and source, the test suite descriptor, the audit source and report) in /artifacts and documentation in /doc. The TCK library dependencies are not part of the distribution and can be downloaded on demand (see readme.txt file in /lib).

You can also download the current source code from GitHub repository.

The TCK project is also available in the Maven Central repository as org.jboss.cdi.tck:cdi-tck-impl. The POM file defines all dependencies required to build the TCK.

Executing the TCK requires a Java EE 7 or better runtime environment (i.e., application server), to which the test artifacts are deployed and the individual tests are invoked. The TCK does not depend on any particular Java EE implementation.

The JSR 346: Contexts and Dependency Injection for Java EE 1.1 reference implementation (RI) project is named Weld. The release stream for JSR 346 is named 2.x. You can obtain the latest release from the download page on Seam Framework website.

Note

Weld is not required for running the CDI TCK, but it can be used as a reference for familiarizing yourself with the TCK before testing your own CDI implementation.

Naturally, to execute Java programs, you must have a Java SE runtime environment. The TCK requires Java 7 or better, which you can obtain from the Java Software website.

The TCK requires the following two Java runtime environments:

You should refer to vendor instructions for how to install the runtime environment.

The rest of the TCK software can simply be extracted. It's recommended that you create a folder named jsr346 to hold all of the jsr346-related projects. Then, extract the TCK distribution into a subfolder named tck. If you have downloaded the Weld distribution, extract it into a sibling folder named weld. The resulting folder structure is shown here:

jsr346/
   weld/
   tck/

Each test class is treated as an individual artifact. All test methods (i.e., methods annotated with @Test) in the test class are run in the application, meaning bean discovery occurs exactly once per artifact and the same BeanManager is used by each test method in the class.

Running the TCK against the CDI RI (Weld) and JBoss AS

Currently there is no JBoss AS release that bundles Weld 2.x. However it's possible to patch the latest JBoss AS 8.x snapshot with provided Weld subsystem. To install and patch JBoss AS 8.x:

The CDI TCK distribution includes a TCK runner that executes the TCK using Weld as the CDI implementation and JBoss AS as the Java EE runtime. To run the TCK:

  • You need to install Maven. You can find documentation on how to install Maven in the Maven: The Definitive Guide book published by Sonatype.

  • Next, instruct Maven to run the TCK:

    cd jsr346/tck/weld/jboss-tck-runner
    mvn test -Dincontainer
  • TestNG will report, via Maven, the outcome of the run, and report any failures on the console. Details can be found in target/surefire-reports/TestSuite.txt.

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 TCK test suite, putting these settings into practice.

The CDI TCK is built atop Arquillian and 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 artifacts/cdi-tck-impl-suite.xml artifact provided in the TCK distribution must be run by TestNG 6.3 (described by the TestNG documentation 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="CDI TCK" verbose="0" configfailurepolicy="continue">
   <test name="CDI TCK">
      ...
      <classes>
         <class name="org.jboss.cdi.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.

The TCK makes use of the Java 1.4 keyword assert; you must ensure that the JVM used to run the application server is started with assertions enabled. See Programming With Assertions for more information on how to enable assertions.

Tests within the jms test group require some basic Java Message Service configuration. A connection factory, a queue destination for PTP messaging domain and a topic destination for pub/sub messaging domain must be available via JNDI lookup. The corresponding JNDI names are specified with configuration properties - see Section 4.1, “TCK Properties”.

Tests within the persistence test group require basic data source configuration. The data source has to be valid and JTA-based. The JNDI name of the DataSource is specified with configuration property - see Section 4.1, “TCK Properties”.

Tests within the installedLib test group require the CDI TCK cdi-tck-ext-lib artifact to be installed as a library (see also Java EE 6 specification, section EE.8.2.2 "Installed Libraries").

Tests within the systemProperties test group require the following system properties to be set:


This chapter covers the two types of reports that can be generated from the TCK, an assertion coverage report and the test execution results. The chapter also justifies why the TCK is good indicator of how accurately an implementation conforms to the JSR 346 specification.

A specification can be distilled into a collection of assertions that define the behavior of the software. This section introduces the CDI TCK coverage report, which documents the relationship between the assertions that have been identified in the JSR 346 specification document and the tests in the TCK test suite.

The structure of this report is controlled by the assertion document, so we'll start there.

The CDI TCK developers have analyzed the JSR 346 specification document and identified the assertions that are present in each chapter. Here's an example of one such assertion found in section 2.3.3:

The assertions are listed in the XML file impl/src/main/resources/tck-audit.xml in the CDI TCK distribution. Each assertion is identified by the section identifier of the specification document in which it resides and assigned a unique paragraph identifier to narrow down the location of the assertion further. To continue with the example, the assertion shown above is listed in the tck-audit.xml file using this XML fragment:



         <section id="declaring_bean_qualifiers" title="Declaring the qualifiers of a bean">
          ...
          <assertion id="d">
             <text>Any bean may declare multiple qualifier types.</type>
          </assertion>
          ...
            </section>
         

The strategy of the CDI TCK is to write a test which validates this assertion when run against an implementation. A test case (a method annotated with @Test in a test class) is correlated with an assertion using the @org.jboss.test.audit.annotations.SpecAssertion annotation as follows:

@Test

@SpecAssertion(section = DECLARING_BEAN_QUALIFIERS, id = "d")
public void testMultipleQualifiers()
{
  Bean<?> model = getBeans(Cod.class, new ChunkyBinding(true), new WhitefishBinding()).iterator().next();
  assert model.getBindings().size() == 3;
}

To help evaluate the distribution of coverage for these assertions, the TCK provides a detailed coverage report. This report is also useful to help implementors match tests with the language in the specification that supports the behavior being tested.

The coverage report is an HTML report generated as part of the TCK project build. Specifically, it is generated by an annotation processor that attaches to the compilation of the classes in the TCK test suite, another tool from the JBoss Test Utils project. The report is only generated when using Java 6 or above, as it requires the annotation processor.

mvn clean install

The report is written to the file target/coverage.html in the same project. The report has five sections:

The coverage report is color coded to indicate the status of an assertion, or group of assertions. The status codes are as follows:

For reasons provided in the tck-audit.xml document and presented in the coverage report, some assertions are not testable.

The coverage report does not give any indication as to whether the tests are passing. That's where the TestNG reports come in.

The CDI TCK test suite is really just a TestNG test suite. That means an execution of the CDI TCK test suite produces the same reports as TestNG does. This section will go over those reports and show you where to find each of them.

When the CDI TCK test suite is executed during the Maven test phase of the TCK runner project, TestNG is invoked indirectly through the Maven Surefire plugin. Surefire is a test execution abstraction layer capable of executing a mix of tests written for JUnit, TestNG, and other supported test frameworks.

Why is this relevant? It means two things. First, it means that you are going to get a summary of the test run on the commandline. Here's the output generated when the tests are run using standalone mode.

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running TestSuite
[XmlMethodSelector] CLASSNAME:org.jboss.testharness.impl.testng.DisableIntegrationTestsMethodSelector
[XmlMethodSelector] SETTING PRIORITY:0
[XmlMethodSelector] CLASSNAME:org.jboss.testharness.impl.testng.ExcludeIncontainerUnderInvestigationMethodSelector
[XmlMethodSelector] SETTING PRIORITY:0
Tests run: 441, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 22.816 sec

Results :

Tests run: 441, Failures: 0, Errors: 0, Skipped: 0

If the Maven reporting plugin that complements Surefire is configured properly, Maven will also generate a generic HTML test result report. That report is written to the file test-report.html in the target/surefire-reports directory of the TCK runner project. It shows how many tests were run, how many failed and the success rate of the test run.

The one drawback of the Maven Surefire report plugin is that it buffers the test failures and puts them in the HTML report rather than outputting them to the commandline. If you are running the test suite to determine if there are any failures, it may be more useful to get this information in the foreground. You can prevent the failures from being redirected to the report using the following commandline switch:

mvn test -Dsurefire.useFile=false

The information that the Surefire provides is fairly basic and the detail pales in comparison to what the native TestNG reports provide.

In this part you learn how to execute the CDI TCK on the CDI reference implementation (Weld). First, you are walked through the steps necessary to execute the test suite on Weld. Then you discover how to modify the TCK runner to execute the test suite on your own implementation. Finally, you learn how to debug tests from the test suite in Eclipse.

One of the requirements of an implementation passing the TCK is for it to pass the CDI signature test. This section describes how the signature file is generated and how to run it against your implementation.

Just for fun (and to confirm that the signature test is working correctly), you can try the following:

1) Edit cdi-api.sig

2) Modify one of the class signatures - in the following example we change one of the constructors for BusyConversationException - here's the original:

CLSS public javax.enterprise.context.BusyConversationException
cons public BusyConversationException()
cons public BusyConversationException(java.lang.String)
cons public BusyConversationException(java.lang.String,java.lang.Throwable)
cons public BusyConversationException(java.lang.Throwable)
supr javax.enterprise.context.ContextException
hfds serialVersionUID

Let's change the default (empty) constructor parameter to one with a java.lang.Integer parameter instead:

CLSS public javax.enterprise.context.BusyConversationException
cons public BusyConversationException(java.lang.Integer)
cons public BusyConversationException(java.lang.String)
cons public BusyConversationException(java.lang.String,java.lang.Throwable)
cons public BusyConversationException(java.lang.Throwable)
supr javax.enterprise.context.ContextException
hfds serialVersionUID

3) Now when we run the signature test using the above command, we should get the following errors:

Missing Constructors
--------------------

javax.enterprise.context.BusyConversationException:         constructor public javax.enterprise.context.BusyConversationException.BusyConversationException(java.lang.Integer)

Added Constructors
------------------

javax.enterprise.context.BusyConversationException:         constructor public javax.enterprise.context.BusyConversationException.BusyConversationException()


STATUS:Failed.2 errors

This chapter explains how to run the TCK on Weld as well as your own implementation. The CDI TCK uses the Maven Surefire plugin and the Arquillian test platform to execute the test suite. Learning to execute the test suite from Maven is prerequisite knowledge for running the tests in an IDE, such as Eclipse.

To execute the TCK test suite against Weld, first switch to the jboss-tck-runner directory in the extracted Weld distribution:

cd weld/jboss-tck-runner

Then execute the Maven life cycle through the test phase:

mvn test

Without any command-line flags, the test suite is run in standalone mode (activating weld-embedded Maven profile), which means that any test within the integration or javaee-full TestNG group is skipped. This mode uses the Weld EE Embedded Arquillian container adapter to invoke the test within a mock Java EE life cycle and capture the results of the test. However, passing the suite in this mode is not sufficient to pass the TCK as a whole. The suite must be passed while executing using the in-container mode.

To execute the test suite using in-container mode with the JBoss TCK runner, you first have to setup JBoss AS as described in the ??? callout.

Then, execute the TCK runner with Maven as follows:

mvn test -Dincontainer

The presence of the incontainer property activates an in-container Maven profile. This time, all the tests in the test suite are executed.

Note

In order to run the TCK Test Suite in-container mode an Arqullian Container Adapter is required. See also Arqullian reference guide.

The Arquillian will also start and stop the application server automatically (provided a managed Arqullian Container Adapter is used).

Since in-container tests are executed in a remote JVM, the results of the test must be communicated back to the runner over a container-supported protocol. The Arquillian provides servlet-based communication over HTTP.

As you have learned, when the test suite is executing using in-container mode, each test class is packaged as a deployable archive 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, you may find it helpful to inspect the archive after it's generated. The TCK (or Arquillian respectively) can accommodate this type of inspection by "dumping" the generated archive to disk.

The feature just described is activated in the Arquillian configuration file (Section 4.2, “Arquillian settings”). In order to export the test archive you'll have to add the deploymentExportPath property to engine tag and assign a relative or absolute directory where the test archive should be exported, e.g.:

            <engine>
                <property name="deploymentExportPath">target/</property>
            </engine>
         

Arquillian will export the archive to that location for any test you run.

To enable the export for just a single test, use the VM argument arquillian.deploymentExportPath:

-Darquillian.deploymentExportPath=target/deployments/

This chapter explains how to run individual tests using the Eclipse TestNG plugin. It covers running non-integration tests in standalone mode and integration tests (as well as non-integration tests) in in-container mode. You should be able to use the lessons learned here to debug tests in an alternate IDE as well.

Using an existing test harness (TestNG) allows the tests to be executed and debugged in an Integrated Development Environment (IDE) using available plugins. Using an IDE is also the easiest way to execute a test class in isolation.

The TCK can be executed in any IDE for which there is a TestNG plugin available. Running a test from the CDI TCK test suite using the Eclipse TestNG plugin is almost as simple as running any other TestNG test. You can also use the plugin to debug a test, which is described in the next chapter.

Before running a test from the TCK test suite in Eclipse, you must have the Eclipse TestNG plugin and either the m2e plugin or an Eclipse project generated using the Maven 2 Eclipse plugin (maven-eclipse-plugin). Refer to Section 3.3, “Eclipse Plugins” for more information on these plugins.

Note

In order to run the TCK tests in Eclipse you must have CDI TCK and Weld JBoss TCK runner projects imported. Get the source from GitHub repositories https://github.com/jboss/cdi-tck and https://github.com/weld/core.

With the m2e plugin installed, Eclipse should recognize the CDI TCK projects as valid Eclipse projects (or any Weld project for that matter). Import them into the Eclipse workspace at this time. You should also import the Weld projects if you want to debug into that code, which is covered later.

Tip

If you choose to use the Maven 2 Eclipse plugin (maven-eclipse-plugin), you should execute the plugin in both the tck and weld projects:

cd tck
mvn clean eclipse:clean eclipse:eclipse -DdownloadSources -DdownloadJavadocs
cd ../weld
mvn clean eclipse:clean eclipse:eclipse -DdownloadSources -DdownloadJavadocs

When setting up your Eclipse workspace, we recommended creating three workings sets:

The dependencies between the projects will either be established automatically by the m2e plugin, based on the dependency information in the pom.xml files, or as generated by the mvn eclipse:eclipse command.

Your workspace should appear as follows:

Weld
  cdi-api
  weld-core
  ...
CDI TCK
  cdi-tck-api
  cdi-tck-impl
  cdi-tck-parent
Weld JBoss TCK Runner
  weld-jboss-runner-tck11
  weld-porting-package-tck11

The tests in the TCK test suite are located in the cdi-tck-impl project. You'll be working within this project in Eclipse when you are developing tests. However, as you learned earlier, there are no references to a CDI implementation in the TCK. So how can you execute an individual test in Eclipse? The secret is that you need to establish a link in Eclipse (not in Maven) between the cdi-tck-impl project and your TCK runner project, which in this case is weld-jboss-runner-tck11 (the project in the jboss-tck-runner/1.1 directory).

Here are the steps to establish the link:

Of course, the weld-jboss-runner-tck11 also depends on the cdi-tck-impl at runtime (so it can actually find the tests to execute). But m2e plugin doesn't distinguish between build-time and runtime dependencies. As a result, we've created a circular dependency between the projects. In all likelihood, Eclipse will struggle (if not fail) to compile one or more projects. How can we break this cycle?

As it turns out, the TCK runner doesn't need to access the tests to build. It only needs its classes, configurations and other dependencies at runtime (when the TestNG plugin executes). Therefore, we can disable Resolve dependencies from workspace projects setting on weld-jboss-runner-tck11 project:

As you have learned, the TCK determines how to behave based on the values of system properties or properties defined in META-INF/cdi-tck.properties classpath resources. In order to run the tests, you need to add a properties file to the classpath or define corresponding system properties.

The CDI TCK project conveniently provides the properties file src/test/resources/META-INF/cdi-tck.properties that contains all of the necessary properties for testing in Eclipse. You have to tune the org.jboss.cdi.tck.libraryDirectory and org.jboss.cdi.tck.testDataSource properties to point to the relative location of the related projects and specify the name of test datasource. The properties should be defined as follows:

You are now ready to execute an individual test class (or artifact). Let's start with a test artifact capable of running in standalone mode.

This chapter explains how to debug standalone and integration tests from the TCK test suite in Eclipse. You should be able to use the lessons learned here to debug tests in an alternate IDE as well.

In order to debug an integration test, or any test run using in-container mode, the test must be configured to run in-container, as described in Section 8.4, “Running integration tests”, and you must attach the IDE debugger to the container. That puts the debugger on both sides of the fence, so to speak.

Since setting up a test to run in-container has already been covered, we'll look at how to attach the IDE debugger to the container, and then move on launching the test in debug mode.