Uploaded image for project: 'Arquillian'
  1. Arquillian
  2. ARQ-867

Arquillian should warn if javax.inject.* annotations used w/o beans.xml

    XMLWordPrintable

Details

    • Feature Request
    • Resolution: Unresolved
    • Major
    • None
    • 1.0.0.Final
    • None
    • None

    Description

      Because Arquillian requires the use of ShrinkWrap and individual selection of parts of the project to be tested, it's easy to leave beans.xml out and have CDI injection (javax.inject.Inject, etc) fail silently. A log message is emitted in the server logs about the BeanManager not being found, but there's no other indication of the problem until the tests fail with NPEs in injected fields. Missing/unsatisfied/duplicate dependencies are not caught and resolved, so if the injected fields aren't used directly a test may appear to pass when it's really just not testing the CDI stuff you thought you were testing.

      This issue is particularly easy to stumble on because different archive types require beans.xml to appear in different locations, and ShrinkWrap doesn't have any API for automatically placing beans.xml in the correct archive specific location. (See https://issues.jboss.org/browse/SHRINKWRAP-396).

      It'd be a usability enhancement to Arquillian if it'd detect the case where javax.inject.Inject annotations were used but CDI was not present, and emit an explicit warning in the logs and test output.

      (Personally I think the CDI spec allowing containers to silently ignore javax.inject.Inject when no CDI implementation is present was a mistake - they should be required to emit a warning at minimum. So much pain would be saved for newbies.)

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              ringerc_jira Craig Ringer (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated: