GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - weld/weld-testing: Set of test framework extensions (JUnit 4, JUnit Jupiter, Spock) to enhance the testing of CDI components via Weld. Different versions support different Weld releases.

BranchesTags
Open more actions menu

Latest commit

 

History

373 Commits
373 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
junit-common
junit-common
 
 
junit-jupiter
junit-jupiter
 
 
junit4
junit4
 
 
spock
spock
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
dco.txt
dco.txt
 
 
pom.xml
pom.xml
 
 

Repository files navigation

Weld Testing Extensions

Maven Central License

The primary goal of this project is to provide simple and fast tools for CDI unit/component testing. The tools are implemented as JUnit 4, JUnit Jupiter and Spock extensions.

⚠️ Version 6.x of this extension supports Weld 7.0 (CDI 5.0). The JUnit Jupiter extension artifact has been renamed from weld-junit5 to weld-junit-jupiter — see the migration guide for details.

Java 17 or newer is required.

The What

Extensions in this repository allow you to write unit tests for your beans regardless of the target environment (Java SE, Jakarta EE, etc.). They start a real CDI container with minimal configuration meaning you can leverage all bean capabilities - injection, interception, events, etc. - without the need for mocking. These extensions boot up CDI container before each test container run and shut it down afterwards. You have the power to customize what beans, extensions, interceptors (and so on) are going to be in the container. Furthermore, you can @Inject directly in your test class - and the list goes on...

The Why

As a matter of fact, one could have a unit test for CDI bean without running a container, but that would present quite a few drawbacks. Simulating field injection to start with, then interceptors and/or decorators - all in all, quite a challenge. There are frameworks to make this easier such as Mockito; but use too many mocks and things get tangled real quick. So we came with JUnit/Spock extensions which allow you to use actual CDI container instead of complex simulations. There is no need to change the way you develop your CDI components if you have a real container to test it with. Besides, it's easy to combine this approach with mocking frameworks (see for instance Adding mock beans).

How To Use Each Extension

This project consists of four modules. Below is a list with links to detailed README of each extension:

  • JUnit 4 extension
    • JUnit 4 extension using @Rule and @ClassRule mechanism
  • JUnit Jupiter
    • JUnit Jupiter extension using the @ExtendWith mechanism
  • JUnit-common
    • Houses the code shared by the JUnit and Spock extensions
  • Spock
    • Spock framework extension

About

Set of test framework extensions (JUnit 4, JUnit Jupiter, Spock) to enhance the testing of CDI components via Weld. Different versions support different Weld releases.

weld.cdi-spec.org/

Resources

Readme
Apache-2.0 license

Code of conduct

Code of conduct

Contributing

Contributing
Activity
Custom properties

Stars

116 stars

Watchers

7 watching

Forks

35 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.