How can I run maven tests against a previous deployed artifact of the same artifact?

I have an abc artifact that has some tests. I have different versions of abc in my repository. Now I want to be able to run the latest tests against the "old build" of the project.

I tried to add the artifact of dependency testing itself, but this (of course) leads to a cyclic Maven reactor test error when creating tests with:

mvn compiler: testCompile mvn surefire: test

Is there any smart way to run tests with a previous old build / artifact?

Should I create a new pom.xml in which I determine the execution of the solo test? Or should I add a postfix to my current artifact when running tests? (This will avoid a cyclic link error)

+4
source share
2 answers

Separate the tests into a separate module / project, which depends on the classes that it tests. Then create separate profiles in which you change the dependency for older versions.

+3
source

The problem that I foresee with what you are trying to do is that the package phase occurs after the maven lifecycle testing phase. Which means to me that maven runs unit tests against compiled classes, and not a physical jar file (generated in the package phase). Therefore, you will have to replace the contents of the projects / target / classes folder with classes in the "old" bank.

+1
source

Source: https://habr.com/ru/post/1333189/


All Articles