lundi 26 janvier 2015

PHPUnit "No Tests Executed" if I enable test string comparison

I have a couple of really basic tests written in PHPUnit and for some reason when I enable one of the assertions, I get "No Tests Executed."


I'm not a skilled unit tester, so it's clearly something I'm doing wrong, but I'm having a hard time tracking down a solution.


I'm testing for a string coming back from a Soap server it's either "true" or "false."


In my unit test if I write this



$hasErrors = 'false';
$this->assertTrue('true' == $hasErrors);


I get "No tests executed!"


If I do the following - I know it's not the same test - I'm just curious why this one runs the tests, while that previous doesn't just show a failure but says no test are executed.



$hasErrors = 'false';
$this->assertFalse('true' == $hasErrors);


I would like the failure to fail rather say "No tests executed."


The same thing happens if I use assertNotEquals rather than assertFalse.


Aucun commentaire:

Enregistrer un commentaire