I have this code:
public function testFoo() {
$this->object = newBar();
}
But later, e.g., in method testAdd(), $this->object is null. testAdd executes after testFoo.
Why does this happen, and is there any setUp-like method for whole test case?
Every test method is executed on a new instance of the test case class. There is indeed a setup method that is called before each test, and it’s called
setUp.If you need to share state across all tests for a test case–often ill-advised–you can use the static
setUpBeforeClassmethod.