0

My project uses maven as the build tool, which works well so far.

I have a test module including all test cases of other modules, which is arranged under test/src/test/java/

test module

However, when I create another module (let's call it TestB) and let it depend on the module test, all classes/interfaces defined in module test are invisible to the TestB. I wonder because I put all stuff under test/src/test/java but not test/src/main/java.

But if I move classes to test/src/main/java, the JUnit tool will stop working. Any good ideas on this?

0

1 Answer 1

1

There's some documentation in the Maven documentation on how to do this.

Basically, it comes down to adding this:

<project> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.6</version> <executions> <execution> <goals> <goal>test-jar</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project> 

To your pom.xml, after which you can use the dependency like this:

<dependency> <groupId>com.myco.app</groupId> <artifactId>foo</artifactId> <version>1.0-SNAPSHOT</version> <type>test-jar</type> <scope>test</scope> </dependency> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.