Run JUnit Test with maven dependencies from plugin

Hi Community,

I need to execute a JUnit Test of a project from my plugin.
My approach is this:

  • I search for the TestClass
  • Run it with JUnitCore


This works as long as the TestClass has no maven dependencies.

A solution is to add all the maven dependencies manually to the plugin project
but this will be a loss of portability.

Is there some way to resolve this problem without lack of portability?

Markus

1 comment

I found the solution by myself,

I use Runtime.getRuntime().exec(command) to execute a cmd command and run a Maven task.
With the Surefire plugin from Maven I can easily run the test.

Markus

0

Please sign in to leave a comment.