3

I am running tests with CDI-unit runner and want some classes to be excluded (because they act on CDI events). I tried beans.xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee">
    <scan>
        <exclude name="com.mypackage.**"/>
    </scan> 

</beans>

but CDI-unit seems to be ignoring it. So what is the correct way to exclude the classes with CDI-unit?

Jens Piegsa
  • 7,399
  • 5
  • 58
  • 106
mmm
  • 1,688
  • 16
  • 35

1 Answers1

3

You may provide an alternative of the class you want to exclude, so that the alternative test class is used instead. With CDI Unit you turn on your alternative with @ActivatedAlternatives on your tests, or globally with @ProducesAlternative on your test producer. See more here: http://jglue.org/cdi-unit-user-guide/#alternatives

AFAIK, CDI Unit does not directly support exclusion of beans. But in most cases using alternatives is sufficient.

OndroMih
  • 7,280
  • 1
  • 26
  • 44