Find classpath maven is using for running testng testcase

空扰寡人 提交于 2020-01-22 13:40:06

问题


what options to maven can I use to determine what classpath maven is running a testng test case with?


回答1:


You didn't provide the Maven version, but at least in 3.x (and maybe also 2.x) you can run commands with the -X (debug) option. That way the Test Classpath is printed out before tests are run.

mvn test -X



回答2:


In general you can find the classpath that maven is using by using the built-in maven dependency plugin and its build-classpath goal.

If you want the classpath uses for compiling and running the test you need to select the test dependency scope. This scope is the default, but if you want to be explicit you can set it with -DincludeScope=test.

Other scopes include runtime, compile, provided and system.

Depending on how you want to consume the output you can play with the options -Dmdep.outputFilterFile and -Dmdep.outputFile. The mdep.outputFilterFile makes it easier to parse the output from a script and the outputFile option writes to a file instead which some tools can read directly.

Here are some examples:

$ mvn dependency:build-classpath -DincludeScope=test -Dmdep.outputFilterFile=true|grep 'classpath='
classpath=xxx.jar:yyy.jar
$ mvn dependency:build-classpath -DincludeScope=test -Dmdep.outputFile=cp.txt
$ cat cp.txt
xxx.jar:yyy.jar



回答3:


I couldn't format my response in my comment so submitting the grepped version here:

mvn test -X | grep "maven.dependency.classpath"


来源:https://stackoverflow.com/questions/7898875/find-classpath-maven-is-using-for-running-testng-testcase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!