测试套件和测试组之间有什么区别? [英] What's the difference between test suite and test group?

查看:92
本文介绍了测试套件和测试组之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

测试套件和测试组之间有什么区别?如果我想在phpunit.xml中按测试组(即目录组)组织单元测试,例如测试特定的应用程序模块.

What's the difference between test suite and test group? If I want to organize my unit tests in phpunit.xml in groups of tests (i.e. groups of directiories), e.g. tests for specific application module.

  • phpunit.xml应该如何利用组和测试套件?
  • 如何从命令行运行特定的组/测试套件?
  • How should the phpunit.xml look like to utilize groups and test suites?
  • How to run specific group/test suite from the command line?

类似的问题:

有关XML配置中的测试套件和组的PHPUnit手册:

PHPUnit manual about test suites and groups in xml configuration:

  • http://www.phpunit.de/manual/3.4/en/appendixes.configuration.html
  • http://www.phpunit.de/manual/current/en/organizing-tests.html

如何配置phpunit --list-groups中显示的phpunit.xml中的组?

How to configure the groups in phpunit.xml, that phpunit --list-groups showed them?

推荐答案

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

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.

这篇关于测试套件和测试组之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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