开发者

Junit test case - time elapsed is 0.00

Time elapsed (time taken?) to run(and pass) my Junit test case is shown as 0.00. I have tried failing the test case (by doing assertEquals for a wrong value) and its still showing time elapsed as 0.00.

The rest of test cases have non-zero time elapsed values.

EDIT: Assumption - I assumed that it would surely take non-zero time to execute and that if it didn't happen, nothing was happening within the test case - example, 开发者_开发技巧I have a if condition in there and no corresponding else. So, if the condition failed, it just came out of the method without doing anything and since an error didn't occur, it didn't fail the test either.

Is there any reason this is happening? Am I missing something?

Thanks, Pratyusha.


It's not clear why you think it should be non-zero. Is it possible that your test case is just passing (or failing) really quickly?

Just for the sake of experimentation, put a Thread.sleep(1000) call in there... if that changes things, it suggests that everything's fine and your test is just fast.

Are all your test methods shown to be executing? It's not something simple like failing to annotate the methods or failing to keep to the naming convention of testXXX (depending on which version of JUnit you're using)?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜