Overview

Other MyFaces Extensions

Community

Development

Sponsorship

Skip to end of metadata
Go to start of metadata

JUnit 4 for CDI Java-SE tests

If just plain unit testing is needed without JEE APIs it's possible to use the AbstractCdiAwareTest

Simple JUnit 4 test with dependency injection

JUnit 4 for CDI Java-EE tests

If it's required to test e.g. request scoped beans it's possible to use the AbstractServletAwareTest

Simple JUnit 4 test with dependency injection for the Servlet API

If it's required to test e.g. grouped conversation scoped beans it's possible to use the AbstractServletAwareTest

Simple JUnit 4 test with dependency injection for the JSF API

Needed modules and dependencies

Because the unit-test modules will never be needed in production builds, you have to add the CODI-test modules manually, even if you are using one of the all-in-one packages. You'll need at least the myfaces-extcdi-junit-support-module for general JUnit support. And depending on your needs, you'll also need the myfaces-extcdi-owb-support-module and myfaces-extcdi-jsf-support-module. Don't forget to also include the needed (test)modules of the CDI implementation. In case of OWB, you'll need cditest and cditest-owb from the org.apache.openwebbeans.test group. For convenience, here's a pom-snippet to pick the needed dependencies from:

Snippet from pom.xml with example CODI-test-dependencies.

Examples

An example is available here.

  • No labels