JUnit Integration Tests的'IT.java'文件名后缀(而不是'Test.java')是否惯例? [英] Is the 'IT.java' filename Suffix (instead of 'Test.java') for JUnit Integration Tests a convention?

查看:129
本文介绍了JUnit Integration Tests的'IT.java'文件名后缀(而不是'Test.java')是否惯例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我习惯于用 * 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


不,所有测试都放在一个目录中,我们通过以下方式区分单元测试和集成测试:文件名后缀上的模式匹配。

No, all the Tests go in the one directory, and we distinguish the Unit Tests from the Integration tests by pattern matching on the file name suffix.

所以我上面的文件将成为 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 后缀是 Maven故障安全插件。测试目录中所有后缀为 IT 的类均由此插件在 integragion-test 阶段执行。 (带有后缀 Test 的测试由 Maven Surefire插件处于 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')是否惯例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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