使用 maven 运行单个测试方法 [英] Run a single test method with maven

查看:36
本文介绍了使用 maven 运行单个测试方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道您可以使用以下方法在某个类中运行所有测试:

I know you can run all the tests in a certain class using:

mvn test -Dtest=classname

但是我想运行一个单独的方法并且 -Dtest=classname.methodname 似乎不起作用.

But I want to run an individual method and -Dtest=classname.methodname doesn't seem to work.

推荐答案

在Maven中运行单个测试方法,需要提供如下命令:

To run a single test method in Maven, you need to provide the command as:

mvn test -Dtest=TestCircle#xyz test

其中 TestCircle 是测试类名,xyz 是测试方法.

where TestCircle is the test class name and xyz is the test method.

通配符也可以使用;在方法名和类名中.

Wild card characters also work; both in the method name and class name.

如果您在多模块项目中进行测试,请使用 -pl 指定测试所在的模块.

If you're testing in a multi-module project, specify the module that the test is in with -pl <module-name>.

对于集成测试,使用 it.test=... 选项而不是 test=...:

For integration tests use it.test=... option instead of test=...:

mvn -pl <module-name> -Dit.test=TestCircle#xyz integration-test

这篇关于使用 maven 运行单个测试方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆