maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Florian Sch├Ątz <>
Subject Where to keep test only files that are needed in multiple projects?
Date Thu, 22 Dec 2016 14:33:28 GMT

let's assume a simple maven project consisting of two modules:

 - myproject-basicstuff 
 - myproject-application which myproject-application has the myproject-basicstuff as a

Now let's say we have an arbitrary class in myproject-basicstuff:

    public class Data {
      ...has some data content...


Since I am using AssertJ, I want to create a custom Assert for that...

    public class DataAssert extends AbstractObjectAssert<DataAssert,
Data> {

(If you don't know assertions, simply assume a Hamcrest matcher or

All of this is pretty straight-forward, but now there's one problem:
Where to put the custom assertion?

If I put DataAssert into myproject-basicstuff/src/main/java, then I need
to include AssertJ as a runtime dependency, "polluting" my classpath
with it - because I only actually need AssertJ during test time.

If I put DataAssert into myproject-basicstuff/src/test/java, then I
cannot use it in myproject-application, since the test classpath doesn't
get inherited. 

If I create an additional module myproject-basicstuff-test, then I
cannot use it in myproject-basicstuff, since that would be a circular

So, is there a chance to somehow keep the whole shebang in the test


View raw message