且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

测试套件和测试组之间有什么区别?

更新时间:2023-01-18 15:48:52

测试套件可组织相关的测试用例,而测试组是应用于测试方法的标记.

Test suites organize related test cases whereas test groups are tags applied to test methods.

使用 @group注释您可以使用描述性标记(例如fixes-bug-472facebook-api)标记各个测试方法.运行测试时,您可以在phpunit.xml或命令行中指定要运行(或不运行)的组.

Using the @group annotation you can mark individual test methods with descriptive tags such as fixes-bug-472 or facebook-api. When running tests you can specify which group(s) to run (or not) either in phpunit.xml or on the command line.

我们在这里不必理会测试套件,但是如果您需要跨多个测试进行通用设置和拆卸,它们可能会很有用.我们通过一些测试用例的基类(普通,控制器和视图)来实现.

We don't bother with test suites here, but they can be useful if you need common setup and teardown across multiple tests. We achieve that with a few test case base classes (normal, controller, and view).

我们也都没有使用组,但是我已经可以想到它们的巨大用途了.我们的某些单元测试依赖于外部系统,例如Facebook API.我们模拟该服务以进行常规测试,但是对于集成测试,我们希望针对真实服务运行.我们可以将一个组附加到要在持续集成服务器上跳过的集成测试方法.

We aren't using groups yet, either, but I can already think of a great use for them. Some of our unit tests rely on external systems such as the Facebook API. We mock the service for normal testing, but for integration testing we want to run against the real service. We could attach a group to the integration test methods to be skipped on the continuous integration server.