Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do you get coverage for source code generated by an annotation processor? Edited

I've developed a java annotation processor (here is a good tutorial). I would like to get code coverage of the generated source code and have had no luck. I use maven as the build tool. Note that the class names of the generated source files contain '$$' to minimize the chance of class name collision (e.g., my/package/Foo$$Bar.java). The root of the source tree is target/generated-test-sources/test-annotations (maven's standard location for sources generated during a test compile).

How do I configure the clover maven plugin such that clover2:setup instruments these generated sources?

 

1 answer

0 votes

When using Clover with any code source generation user must ensure code generation happens before Clover instrumentation happens.

With code annotation processors this is a tricky part because those are processed in-the-fly by Java compiler.

What you may want to experiment with is to process the annotations via some plugin, make sure it's invoked before Clover.

 

Out of curiosity, why do you want to track coverage for a generated code? Usually it's a boilerplate code without any valid business logic in it.

Thanks for the explanation and suggestion.

You're correct that it basically generates boilerplate code, but different annotation combinations interact with each other. I have tests that verify the interaction... since I have tests, I want code coverage.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Opsgenie

Investigate deployment-related incidents with Bamboo and Opsgenie together

Back in April of last year one of the major product announcements from Opsgenie was the launch of the Incident investigation view which created a deep connection between Bitbucket and Opsgenie, empow...

151 views 1 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you