How to ignore Methods during Code Coverage

Hello again. This is a quick tip for you, hope it helps.


  • Programming Language: Java
  • Project Management: Apache Maven
  • Use the artifact “cobertura-maven-plugin” from the “org.codehaus.mojo” group.

Now with the solution:

  1. Create a simple annotation with any name you like.

public @interface CoverageIgnore() {


2. Add the previous annotation to the methods you want to ignore.

public User modifyUser(User user) throws DaoException, SecurityException {
  if(user == null) { throw new SecurityException("User null or empty")}

  Userseg userseg;
  List<String> IdProfiles;

  try {
     userseg =;

3. Add the following tags to the plugin in the pom.xml


4. Compile and you should be set. See you at Twitch, guys.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s