Say I have a test file:
ExampleClassTest.php
And the test file has 3 functions:
public function testOne {
$testVariable = 1;
// Assert something
}
public function testTwo {
$testVariable = 1;
// Assert something
}
public function testThree {
// Assert something
}
The first two functions have a shared variable:
$testVariable = 1;
How ever the third one does not. Is it good practice to have the shared variable in setup:
setUp() {
$testVariable = 1;
}
To save repeating code?
Obviously, it is not being used by all functions.
I know it works either way, this is purely from a framework/coding practice perspective.
Aucun commentaire:
Enregistrer un commentaire