I create a new user in testRegisterNewUser and save the username in the class field variable:
private $_userName;
protected function userName ()
{
if (empty($this->_userName)) {
$this->_userName = uniqid('test_');
}
return $this->_userName;
}
public function testRegisterNewUser()
{
$user = new User($this->userName() );
}
After that, I try to use this value in another class method, but $ _ username is not initialized with the original value from testRegisterNewUser !
public function testFundUser()
{
$user = User::findByUsername( $this->userName() );
}
The question is, when I run tests with codecept run,
Does this mean that the class is Codeception\TestCase\Testrecreated for every method call *?
sharp source
share