简体   繁体   中英

What's the difference between test suite and test group?

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 (ie groups of directiories), eg tests for specific application module.

  • How should the phpunit.xml look like to utilize groups and test suites?
  • How to run specific group/test suite from the command line?

Similar question:

PHPUnit manual about test suites and groups in xml configuration:

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.

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).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM