Reputation: 1329
I'm learning JUnit 4. I came across annotation @Test(Timeout=). when I run this test case and if execution takes more than specified milliseconds, if shows as Error. I guess it should be under failure! if someone could explain me why this is an error not failure. Thanks
Upvotes: 2
Views: 795
Reputation: 69339
Failures are for when you make an assertion and it turns out to be false. It means that your code did not produce the correct result to satisfy your test. Or your test code is wrong.
Errors are for when something unexpected has happened and prevented your test completing normally. Timeouts fit nicely into this category - they are a safety net to ensure your build will always complete, even if your tests run away with themselves. By using a timeout, you are not making an assertion about runtime, you are merely defending against infinite builds.
Upvotes: 2