I'm testing a API, in the setup i make a factory to create and save a user, after i request with curl.
after that a clear the user in tearDown like the example below:
private User user;
/**
* @before
*/
public function setup() {
//open connection here
$this->user = UserFactory::makeUser();
$this->user->save();
$this->sendRequestToLoginWihtThatUser($this->user);
}
//execute test
/**
* @after
*/
public function tearDown() {
$this->user->remove();
//close connection here
}
Even though in the middle of the request I a get a error that break the test or in the tests too. I don't want to code stop, I want to execute tearDown to remove the user from my database. Any suggestions? I'm new to testing, so any ideias will help. Thx guys.
Aucun commentaire:
Enregistrer un commentaire