为什么黄瓜会找到“ runTest.java”来运行测试?

Fre*_*ind 1 java junit cucumber

当我编写一些黄瓜测试时,我从一些文档中发现我需要在“ src / test / java / somepackage”下创建一个“ runTest.java”文件,其内容用于配置黄瓜,例如:

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(plugin = {"pretty"})
public class runTest {
}
Run Code Online (Sandbox Code Playgroud)

我发现类名称“ runTest”很有趣,因为如果将其重命名为其他任何名称,mvn test都将找不到它。

我在junit网站上搜索了有关名称转换的信息,但没有找到任何相关文档。只想了解有关它的更多信息。

rda*_*das 6

我相信惯例是:

  • Test*.java 要么
  • *Test.java 要么
  • *TestCase.java

它不是JUnit约定,而是定义它的Maven surefire插件:https : //maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html

参考:https : //scompoprojects.wordpress.com/2016/02/03/junit-test-class-names-are-important-with-maven/