1
votes

I use Simpletest test suites to run all tests, with different configuration methods. I've created one suite per config method, and it sets up the environment and then runs all tests.

Take a look at Adapter.php and Constants.php if that's unclear.

Now there seems to be support for test suites in PHPUnit, but as I understand it, it's merely for grouping tests with no support for setting up the environment or running PHP scripts.

How can I convert my test suites to PHPUnit? I'm open to rethink how the tests are structured :)

2

2 Answers

0
votes

You can use test fixtures to setup your environment either before each test, or before each test suite:

http://www.phpunit.de/manual/3.6/en/fixtures.html#fixtures.more-setup-than-teardown

The methods you are looking for are

  • setUp() and tearDown() (called before/after each single test), and
  • setUpBeforeClass() and tearDownAfterClass() (called before/after each test class (suite)).
0
votes

Apart from restructuring your test suite you should also be aware that the behaviour of the assertions in PHPUnit is different from SimpleTest.

While in SimpleTest you can test on an assertions result and execute further code after a failed assertion, you cannot in PHPUnit: test the return value of a method that triggers an error with PHPUnit

This will likely also force refactoring some of the actual tests.