Does it make sense to test assertArrayHasKey and later test value using assertEquals?
Does it make sense to test assertArrayHasKey and later test it's value using assertEquals, or when I'm expecting specific value, I should 开发者_如何学运维ommit testing testArrayHasKey - I will get "Undefined index: id" in the next assertion anyway.
I'm aware that difference is in feedback (F vs. E) but does it make any difference in real life?
An error will show you that something in your test didn't met your expectations, you as the person writing the test.
For the expectation of the test, it will fail in case of error as well. So you will get a "fail" in both ways.
So it depends what you expect. If in normal operation the array will have the key and you're interested in testing for a specific value, assert the value and you're done. Keep tests simple.
If it's more common that you get an error in there then, your test might not be actually fitting your needs so getting an error will then signal you that you might want to refactor your test(s).
精彩评论