Reputation: 19320
I’m using Eclipse Juno with Java 6 on Mac 10.9.5. I have a Maven (using version 3.2.3) project, “my project” and am trying to compile and run (within Eclipse) a JUnit test that uses a class from another project. In my JUnit test, I have
import org.mainco.subco.test.utils.AbstractNTsubcoTests;
which produces the Eclipse compilation error, “The import org.mainco.subco.test.utils.AbstractNTsubcoTests cannot be resolved.” I have this dependency in “myproject”’s pom.xml file …
<dependency>
<groupId>org.mainco.subco</groupId>
<artifactId>other project</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
which includes the class. Also, in Eclipse, I include the other project that has this class. In a terminal, I can compile and run this Just test just fine. I tried running
mvn eclipse:eclipse
in the terminal in my “myproject”’s root directory and refreshing “my project” within Eclipse (even restarted Eclipse). Yet still, this compilation error remains. How do I make it go away and get my test to compile and run within Eclipse?
Upvotes: 4
Views: 898
Reputation: 1468
I know the question is quite old, but this also happened to me using latest eclipse version in 2020.
In the end, I had to configure the build path of the project, and in the "Source" tab, scroll down to src/test/java folder and change "Contains test resources" from false to true (double click).
Upvotes: 1