I use Deltaspike CdiControl to start up the CDI container for my unit tests. That works fine but there is a problem: If I use this approach for Maven web app the beans.xml
end up in src/main/webapp/WEB-INF
. That means it is not in the META-INF
directory in the target folder during unit tests.
Since the unit tests itself are not a webapp
but a Java SE run the WEB-INF
directory is ignored. I can fix this by adding a second beans.xml
to META-INF
and/or copying the existing beans.xml
to the right folder for unit tests. But this would mean I have to exclude it from the war manually so it seems a bit hackish.
Putting a beans.xml
into src/test/resources/META-INF
does not work because it will only allow the CDI components in target/test-classes
to be detected.
This seems such a common problem that I assume somebody must have run into this before? Or is everybody having a separate Maven module for the components and/or the unit tests?