使用带有命令行选项的 maven 跳过单个测试 [英] Skip single test with maven with command line options

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

问题描述

从命令行使用 Maven 构建项目时,我想跳过单个测试(例如 com.example.MyTest).

I would like to skip a single test (e.g. com.example.MyTest) when building a project with Maven from the command line.

我知道类似的问题,例如这个,但它们都需要修改源代码或pom.xml.我想不做修改.如何仅使用命令行选项排除测试?

I'm aware of similar questions like this one, but they all require either modification of source code or pom.xml. I would like to do without modifications. How can I exclude a test using command line options only?

在阅读了一些文档

mvn clean install -Dtest="*,!com.example.MyTest"

但是测试仍然没有被跳过.我使用的是surefire插件版本2.19和JUnit 4.11.

but the test is still not skipped. I'm using surefire plugin version 2.19 and JUnit 4.11.

推荐答案

事实证明(至少在 Surefire 2.19 中),测试模式不适用于完全限定的类名.所以正确的解决方案是

It turns out that (at least in Surefire 2.19), the test pattern doesn't work with fully qualified class names. So the right solution is

mvn clean install -Dtest="*,!MyTest"

即没有包路径.

在 Surefire 2.19.1 中,应该是可能的 使用完全限定的名称.在 2.19 之前的版本中,两者似乎都不起作用.

In Surefire 2.19.1, it should be possible to use fully qualified names. In versions older than 2.19, neither seems to work.

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

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