本文介绍了除非类在多模块项目上以Test结尾,否则Maven测试不会进行JUnit 4测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行

忽略任何JUnit 4测试,除非该类的名称为* Test.

ignores any JUnit 4 tests unless the name of the class is *Test.

对junit-4.8.2仅具有一个依赖项,并且目标/源配置为1.6

Having just a single dependency to junit-4.8.2 and target/source configured to be 1.6

推荐答案

这是 maven surefire插件中的标准配置.

  • " */Test .java"-包括其所有内容 子目录和所有Java文件名 以测试"开头的.
  • "**/* Test.java"-包括其所有内容 子目录和所有Java文件名 以测试"结尾.
  • "**/* TestCase.java"-包括所有 它的子目录和所有java 以"TestCase"结尾的文件名.
  • "*/Test.java" - includes all of its subdirectories and all java filenames that start with "Test".
  • "**/*Test.java" - includes all of its subdirectories and all java filenames that end with "Test".
  • "**/*TestCase.java" - includes all of its subdirectories and all java filenames that end with "TestCase".

来源:测试的包含和排除(本文也显示了如何添加其他测试类模式.

Source: Inclusions and Exclusions of Tests (this article also shows how you can add additional test class patterns).

这篇关于除非类在多模块项目上以Test结尾,否则Maven测试不会进行JUnit 4测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 14:26