3 Replies Latest reply on May 13, 2011 7:21 AM by Gábor Farkas

    Unit testing CDI enabled applications using Weld SE

    Lefteris Laskaridis Newbie

      I am trying to unit test some CDI beans using Weld SE however i bumped into some problems. The idea is that from within my test class i instantiate the weld container and then use it to retrieve my bean as so:


      WeldContainer weld = new Weld().initialize();
      weld.instance().select(ClassA.class).get();



      My bean class is the following:



      public class ClassA {
      
         @Inject ClassB injectee;
      
         // ...
      
      }



      What happens is that i get a big fat UnsatisfiedResolutionException exception, saying:

      WELD-001308 Unable to resolve managed beans for Types: [class account.ClassA]; Bindings: [@javax.enterprise.inject.Default()]



      a) Does anybody knows what i'm doing wrong? and b) have you figured out an efficient way to test your CDI enabled applications?


      Cheers!


      L.