How can i run maven tests against a previous deployed artifact of the same artifact?
I have an artifact abc which has some tests. I have different versions of abc within my repository. I now want to be able to run the latest tests ag开发者_高级运维ainst the 'old build' of the project.
I tried to add the artifact itself to the test dependencies but this (of course) results in a cyclic reference error of the maven reactor when building the tests via:
mvn compiler:testCompile mvn surefire:test
Is there any smart way to run tests against a previous old build/artifact?
Must i create a new pom.xml in which i define the solo test execution? Or should i add a postfix to my current artifact when executing the tests? (This would avoid a cyclic reference error)
Separate the tests out into a separate module/project that depends on the classes it tests. Then create separate profiles where you change the dependency to be on older releases.
The problem I foresee with what you're trying to do is that the package phase comes after the test phase of the maven lifecycle. Which to me implies that maven runs unit tests against the compiled classes and not the physical jar file (generated in the package phase). You'll therefore have to replace the contents of the projects /target/classes folder with the classes in the "older" jar.
精彩评论