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

查看:1069
本文介绍了使用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 -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< module-name> 。

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天全站免登陆