JUnit" it will succeed, whereas when I use "Cover as -> JUnit" it will fail. Why is that? The code inde..." /> JUnit" it will succeed, whereas when I use "Cover as -> JUnit" it will fail. Why is that? The code inde..." /> JUnit" it will succeed, whereas when I use "Cover as -> JUnit" it will fail. Why is that? The code inde..."/>

Why JUnit "Run as->JUnit" and "Cover as -> Junit" has different behavior?

92 views Asked by At

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?

1

There are 1 answers

4
Jon Skeet On BEST ANSWER

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