1 Reply Latest reply on Oct 4, 2012 5:34 AM by hhcofcmds

    Do JUnit classes have to be in the same directory as main classes for weld to find all classes?

    peteraymond

      Hi, I'm using weld 1.1.8.Final with JUnit 4.10 to test in a Java SE environment.

       

      I use Maven to run tests but encounter the error below:

       

      WELD-001308 Unable to resolve any beans for Types: [class etc etc]

       

      If I put the test classes in the same directory as the main classes with an update to the POM as below everything works.

       

      <testOutputDirectory>${project.build.outputDirectory}</testOutputDirectory>

       

      Do  test and main classes have to be in the same directory ? Being on the classpath does not seem sufficient.

       

      I have the beans.xml location in META-INF and the class I am injecting annotated with @Alternative matching the beans.xml entry.

       

      Any advice would be helpful.

       

      Thanks

       

      Pete

        • 1. Re: Do JUnit classes have to be in the same directory as main classes for weld to find all classes?
          hhcofcmds

          Hi,

          It looks like I succeeded to run weld-se tests in a maven project. My empty beans.xml is in the src/main/resources/META-INF directory, my beans are in the src/main/java and my test class, that initializes the container (new Weld().initialize() ) is under src/test/java.

          It didn't work for the first time, and as I am working in eclipse, it needed some serious refresh and clean many times. It now works from eclipse and with command line 'mvn clean test' as well.

          cheers, Gabor