Question

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?

Was it helpful?

Solution

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 :(

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top