Weld Testing lets you run JUnit tests against a real CDI container, so you can verify injection and other container-managed behavior without starting a full application server. It supports JUnit 4, JUnit Jupiter, and Spock; the current 6.0.0.Final release also brings important Java, Weld, CDI, and Jupiter naming requirements.
What Weld Testing does in a JUnit test
A plain JUnit test can construct a Java class directly or supply mocks. That is useful for isolated business logic, but it does not prove that CDI can resolve the class’s injections or that container-managed behavior works. Weld Testing starts a Weld container for the test run, makes CDI available to the test class, and shuts the container down afterward. The result is a component test: the bean runs under CDI rather than as an ordinary object.
This approach is especially useful when the behavior depends on injection, interceptors, decorators, or CDI event delivery. The extension can also be combined with mocking frameworks, so a test can exercise CDI where it matters and replace unrelated collaborators where appropriate. The project provides integrations for JUnit 4, JUnit Jupiter, and Spock. The 6.0.0.Final announcement says its Jupiter extension works with JUnit 5 and 6. Weld Testing project README · Weld Testing 6.0.0.Final announcement
Weld Testing versus a plain unit test
| Approach | What it verifies | Setup and trade-off |
|---|---|---|
| Direct construction or mocks | Isolated class logic and the behavior of supplied collaborators; it does not establish that CDI wiring, lifecycle, interception, or event behavior works. | Usually the simplest option for a focused unit test. It can miss problems that only appear when CDI manages the bean. |
| Weld Testing | Bean behavior with CDI injection and other supported container behavior active. | Requires the test extension and container setup, but avoids deploying a full application server for CDI component tests. It can still use mocks. |
| Full application environment | Behavior that relies on services outside Weld SE’s documented feature set, such as EJB beans. | Needed when the feature under test depends on enterprise services that a Weld SE test does not provide. |
There are no published setup-time or execution-speed figures in the cited project sources, so this is a fidelity distinction, not a claim that one approach is measurably faster.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →#1 Best Overall
Compatibility requirements in Weld Testing 6.0.0.Final
The Weld project announced version 6.0.0.Final on September 29, 2026. These requirements are specific to that release; do not apply them automatically to older Weld Testing versions.
- Java: 17 or newer.
- Weld: 7.0.0.Final.
- CDI: 5.0.
- JUnit Jupiter artifact: the name changed from
weld-junit5toweld-junit-jupiter. - Jupiter Java package: changed from
org.jboss.weld.junit5toorg.jboss.weld.junit.jupiter. - Custom test enrichers: migration also changes the service-provider file path for custom
WeldJunitEnricherimplementations.
Use the current Weld Testing README for the dependency declaration and registration details for the version you select. Older tutorials can still illustrate the extension concept, but their artifact coordinates and imports may be stale. For example, the 2017 Weld meets JUnit 5 article predates the 6.0.0.Final naming changes.
Rank #2
Choose the Weld line that matches your application
Weld versions are tied to CDI versions, so a testing setup should match the compatibility line used by the application rather than simply selecting the newest number. The Weld getting-started page lists these separate releases, both dated January 14, 2026:
| Weld release | CDI version | Listed release date |
|---|---|---|
| 5.1.7.Final | 4.0 | January 14, 2026 |
| 6.0.4.Final | 4.1 | January 14, 2026 |
Those are not interchangeable with the Weld 7.0.0.Final and CDI 5.0 baseline specified for Weld Testing 6.0.0.Final. Check the application’s Weld/CDI line and the matching Weld Testing documentation before changing versions. Weld Get Started
Rank #3
When Weld SE is enough—and when it is not
Weld can run in Java SE, which is why a CDI test does not inherently require an application server. Weld’s reference documentation describes support for injection with qualifiers and alternatives, several scopes, interceptors, decorators, stereotypes, events, and portable extensions. It also documents an important boundary: EJB beans are not supported in Weld SE. Weld reference documentation
Quick Recap
Best Value
Rank #4
- Use a Weld Testing test when the question is whether CDI-managed components work together—for example, whether an injection point resolves or an interceptor or event affects the result.
- Use direct construction or mocks when the question is confined to a class’s own logic and container behavior is not part of the claim being tested.
- Use a full environment when the behavior depends on EJB beans or other services not supplied by the Weld SE feature set.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

