Configuration
Basics
The XML Configuration contains all your test suites for your tests.
A single test suite defines where to run a subset of your tests. This means you can configure a test run for a specific Docker image and ENV variables.
The tests can then be used from either shared test directories or specific ones for your environment. You can also configure single files that contain the full tests for your use case.
Setup / Teardown
Every test run has a single setup and teardown phase.
If you run tests in Docker images you might want to assign a setup time in seconds. This is the time that SVRUnit will wait before starting your tests.
Make sure you plan enought time to have everything ready before your tests get started.
Test Runners
Every test suite is executed on a specific environment. Depending on what type of environment you chose (Docker, localhost, ...), a different Test Runner is being used to run the tests.
This helps you to reuse your existing tests on different types of environments.
Docker Image
If you want to create tests for your built Docker images, you can provide the following configuration. In that case SVRUnit will always start a new image before executing your tests. It will use a name with "svrunit_" prefix. Containers will be automatically removed on teardown.
You can also assign a comma separated lists of special ENV variables that you want to use when starting the image.
Docker Image Command Runner
You can also run tests by using your Docker image as command runner. In this case, SVRUnit will not launch a new independent container from that image and execute all tests. Instead it will use a simple "docker run" command where the commands of the tests are appended to the inline command.
The difference to the basic launch of a container is, that this option will override the built-in CMD part of the Docker image. So you can also verify this kind of usage when testing Docker images.
The configuration is almost the same as above. Just add the key "dockerCommandRunner" with TRUE.
Docker Container
If you want to start tests in a running Docker Container, provide these configuration values to let SVRUnit know where to run your tests.
Local Tests
If you just want to test your local server, simply configure your test suite without any additional information. This will start all your tests on the executing system.
Advanced
Groups
You can define groups for your Test Suites.
This helps you to build categories of different tests, e.g. all PHP 8.x Docker Images, or all test suites that run "Security" tests.
You can then use these groups for filters when running SVRUnit.
Just define the group you want to run, using the --group=xy argument.
Placeholders
SVRUnit allows you to use placeholders for specific things. Here is a list of available placeholders.
Executable (EXEC)
Use this to define the executable that should be tested.
This is a great way to test different versions of your application with the same tests. This could be a /bin/script version of your framework, next to the phar binary. Both executables tested with the same SVRUnit tests.
You can use the placeholder (($EXEC)) within your tests.
Now create 2 test suites with the same tests, but different executables.
Both of your application versions are now tested with the same test files.
Last updated