Details
-
Task
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.2.1
-
None
Description
When using the DeltaSpike Test-Control module I noticed that unit tests that run perfectly fine with Maven won't run with Gradle at all.
Let's say you have the following producer method to create a SLF4J Logger instance:
LoggerProducer.java
public class LoggerProducer { @Produces @Default public Logger createLogger(final InjectionPoint ip) { Class declaringClass = ip.getMember().getDeclaringClass(); return org.slf4j.LoggerFactory.getLogger(declaringClass); } }
The test for this is also pretty simple:
LoggerProducerTest.java
@RunWith(CdiTestRunner.class) public class LoggerProducerTest { @Inject private Logger logger; @Test public void testCreateLogger() throws Exception { assertThat(logger, is(notNullValue())); } }
Weld as well as OpenWebBeans throw an exception when the unit test is executed by Gradle, because no suitable beans seem to be found for injection. I have attached a running demo project so you can see for yourself.