问题描述
我习惯于用 * Test.java
命名我的JUnit Integration测试,例如 DatabaseConnectionTest.java
并将它们放在自己的集成测试目录中:例如 test / integration / com ...
I was used to naming my JUnit Integration tests with a *Test.java
on the end eg DatabaseConnectionTest.java
and placing them in their own integration test directory: eg test/integration/com...
加入后我指导的一个新项目
On joining a new project I was directed
所以我上面的文件将成为 DatabaseConnectionIT.java
So my file above would become DatabaseConnectionIT.java
现在我可以看到其中的逻辑。测试运行器脚本可以仅对要查找的文件进行模式匹配,所有测试都位于一个位置。
Now I can see the logic in this. The test runner script can just pattern match for the files it is looking for, and all the tests are in the one location.
但是我从未听说过该公约。
But I had never heard of the convention.
我的问题是:是'IT.java'
文件名后缀(而不是'Test.java'
)for JUnit Integration测试一个约定?
My question is: Is the 'IT.java'
filename Suffix (instead of 'Test.java'
) for JUnit Integration Tests a convention?
推荐答案
IT.java
后缀是。测试目录中所有后缀为 IT
的类均由此插件在 integragion-test
阶段执行。 (带有后缀 Test
的测试由处于 test
阶段。)
The IT.java
suffix is a convention used by the Maven Failsafe Plugin. All classes in the test directory that have the suffix IT
are executed by this plugin in the integragion-test
phase. (Tests with suffix Test
are exectued by the Maven Surefire Plugin in the test
phase.)
这篇关于JUnit Integration Tests的'IT.java'文件名后缀(而不是'Test.java')是否惯例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!