weld / weld-testing

Set of test framework extensions (JUnit 4, JUnit 5, Spock) to enhance the testing of CDI components via Weld. Supports Weld 5.
http://weld.cdi-spec.org/
Apache License 2.0
102 stars 30 forks source link

Question: does it work with newest CDI and Weld? #147

Closed sajanssens closed 2 years ago

sajanssens commented 2 years ago

I tried to make weld-testing work with most recent versions of CDI and Weld, i.e. jakarta.enterprise:jakarta.enterprise.cdi-api:4.0.1 and org.jboss.weld.se:weld-se-core:5.0.1.Final.

It doesn't seem to work with both Java 11 or 17. I tried the SimpleTest example and I got:

org.jboss.weld.exceptions.IllegalArgumentException: WELD-001408: Unsatisfied dependencies for type Foo with qualifiers @Default at injection point [BackedAnnotatedField] @Inject com.example.dao.SimpleTest.foo

I've read that you need Junit5 and Java 11, but what are the supported Weld and CDI versions?

manovotn commented 2 years ago

Hello,

as the README states:

Version 4.x of this extension supports Weld 5.0 (CDI 4.0) along with jakarta namespace

Project has dependencies on CDI 4 (pom.xml) and Weld 5 (pom.xml). Note that the fact that Weld version isn't newest doesn't mean you cannot declare your own newer, in fact you should.

Furthermore, when you checkout the main branch and do mvn clean install, you will run tests (JUnit 5 included) with CDI 4/Weld 5. As for JDKs, CI setup runs on JDK 11 and 17 and runs just fine.

You can take a look at the JUnit 5 tests that are here for some inspiration - https://github.com/weld/weld-testing/tree/master/junit5/src/test/java/org/jboss/weld/junit5 Or you can point me to your code and I can try to spot what's the issue. Either way, this extension should definitely work with CDI 4 and Weld 5 :)

sajanssens commented 2 years ago

Hi Matej,

Thanks for your swift reply. I'm sorry I didn't see that part of the readme myself.

Indeed, when I write a test in a new project, I works like a charm. Thanks to this I know better where to look for the root cause now. Thanks.

manovotn commented 2 years ago

@sajanssens I will close this issue now, but if you are having issues troubleshooting that failure, don't hesitate to come back and ask more questions!