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
look like to utilize groups and test suites?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?
A test case answers the question: What am I going to test? You develop test cases to define the things that you must validate to ensure that the system is working correctly and is built with a high level of quality. A test suite is a collection of test cases that are grouped for test execution purposes.
A test suite is a set of test cases which are logically connected. Eg: test cases which test the same functionality of an app. A test plan is plan how you want to execute your tests to reach your desired test coverage.
In software development, a test suite, less commonly known as a validation suite, is a collection of test cases that are intended to be used to test a software program to show that it has some specified set of behaviors.
For example, you can have a test suite for smoke testing, a suite for API testing, a suite for mobile testing, and a suite each per module like a User module test suite, a Task module test suite, etc. Test suites also help gauge the progress of underlying test cases during execution.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With