Uploaded image for project: 'DeltaSpike'
  1. DeltaSpike
  2. DELTASPIKE-821

check compatibility with gradle

    XMLWordPrintableJSON

Details

    • Task
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.2.1
    • 1.3.0
    • Documentation, TestControl
    • 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.

      Attachments

        1. cdi-logging.zip
          58 kB
          Mario-Leander Reimer

        Activity

          People

            johndament John D. Ament
            mario-leander.reimer Mario-Leander Reimer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: