How to force Emma code coverage report to ignore some methods?
Asked Answered
D

2

16

Some methods, such as auto-generated getters, setters, equals and toString, are trivial for test. However, if they aren't added into the testing classes, the code coverage percentage (calculated using Emma) is reduced and may crash our system build.

How can I force emma to ignore these methods in the code coverage percentage?

Regards,

Felipe

Dissatisfied answered 2/12, 2010 at 15:37 Comment(0)
S
17

From the EMMA FAQ:

A feature to allow EMMA users to mark arbitrary methods as excluded from coverage is being considered for future versions.

So unfortunately this doesn't seem to be possible at the moment. There's an open feature request for this in EMMA's tracker.

Splendiferous answered 23/6, 2011 at 10:24 Comment(1)
Any update on this? This answer is almost 3 years old already.Extremism
M
0

I would argue that every bit of code should be covered, including getters and setters, toString, equals and hash code.

I have seen many a pull requests with:

public void setName(String name)
{
   name = name; // instead of this.name = name
}

There are tools out there to help write these cumbersome tests. ToStringVerifier being one, EqualsVerifier being another.

Millimicron answered 30/11, 2018 at 16:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.