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?
Asked
Active
Viewed 75 times
1 Answers
3
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 :(

Jon Skeet
- 1,421,763
- 867
- 9,128
- 9,194
-
-
1@Edmond: If you don't have any way of making the method any smaller, I suspect not - at least, not with whatever coverage tool you're currently using. You may find that different coverage tools have different instrumentation footprints - and you may even be able to reduce the instrumentation of your current tool. – Jon Skeet Aug 29 '13 at 18:02
-
Is it possible to tell the coverage tool to skip this class. This class is actually an auto generated class(that's why we lose control of its size) and not really important. – Edmond Aug 29 '13 at 18:44
-
@Edmond: I don't know which coverage tool you're using - I don't know whether there's something built into JUnit these days, or whether it's something separate like EMMA. – Jon Skeet Aug 29 '13 at 18:45