I have a JUnit test. But when I use "Run as -> JUnit" it will succeed, whereas when I use "Cover as -> JUnit" it will fail. Why is that? The code indeed has some problem. In the code I'm using some legacy code(I have no access to change it) which contains a too huge method (over 64KB). Why "Run as -> JUnit" cannot expose this problem?

有帮助吗?

解决方案

When you run with "Cover as" the instrumentation will add extra code in your method (to report when each line/expression is hit within the tests). If your message is already very large, that extra instrumentation may well be pushing it over the 64K limit.

It doesn't mean there's anything wrong with the code - it just means you won't be able to use it in coverage tests :(

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top