PHPUnit -setUp() – does it run before and after each test case?

setUp() runs before every single test method, tearDown() runs after each test method.

PHPUnit Manual – Chapter 4 Fixures:

Before a test method is run, a template method called setUp() is invoked

Once the test method has finished running, whether it succeeded or failed, another template method called tearDown() is invoked

See https://phpunit.de/manual/current/en/fixtures.html

Leave a Comment