Hello, currently I am learning to write a test unit for my application.
I write a test function that depends on other test function. So it must running the first test and continue to second test.
I am trying to write like this
public function testConfirm(){
...
$student = $this->student('first');
}
/**
* @depends testConfirm
*/
public function testUnConfirm(){
....
$student->unconfirm(); //<= it doesn't recognise the $student.
}
but unfortunately it’s not working. Did I miss something?
public function testConfirm(){
$student = $this->student('first');
//...
return $student;
}
/**
* @depends testConfirm
*/
public function testUnConfirm($student){
$student->unconfirm();
}
well, I think in most case we need dependencies test. Supposed we want to test create and delete. It’s faster to test the create first, and get that result, to test in delete case.
If you guys are using Netbeans and use the code snippet /* [Enter]
to create your comments it will do them like this:
/*
*/
If you add the @depends annotation it will look like this but will not work.
/*
* @depends test
*/
This is because your freacking block comment needs the two stars at the top in order to recognize the annotations. This is a small detail but I was stuck here until I noticed the second star missing. Your code should look like this: