the last one is important, if you need to test a cdi+ejb based application. just by using a different container-control implementation (deltaspike-cdictrl-openejb) in your build config and adding openejb (/tomee) via org.apache.openejb:openejb-core, you can test cdi-beans as well as ejbs. just inject them as usual via @Inject (also @EJB works as expected).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(CdiTestRunner.class) | |
public class InjectionTest | |
{ | |
@Inject | |
private MyCdiBean bean1; | |
@EJB //or @Inject | |
private MyEjb bean2; | |
@Test | |
public void injection() | |
{ | |
Assert.assertNotNull(this.bean1); | |
Assert.assertNotNull(this.bean2); | |
//... | |
} | |
} |