Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know what classes were touched by a JUnit test

What is an efficient way to programmatically know what classes were touched by a JUnit test?

Right know, I am instrumenting my entire code with JaCoCo, to obtain the code coverage information for every line of code, and then I can figure out what classes were used.

Is it possible to do this without having to instrument all the code at a line of code level?

like image 739
ed s. Avatar asked Oct 14 '25 07:10

ed s.


2 Answers

You can probably do something at the classloader level (this is how some code coverage tools work - from memory, Emma does this, and is open source). Then you can just record which classes are loaded. You might be able to hack something together from one of the OSS coverage tools.

like image 72
Burleigh Bear Avatar answered Oct 16 '25 20:10

Burleigh Bear


I use cobertura which gives lots of nice stats on coverage and can show code coverage by highlighting your code.

There are plugins for eclipse, maven, hudson, jenkins... really easy to use although I have to admit that I haven't tried out any other tools for code coverage.

like image 40
Edd Avatar answered Oct 16 '25 19:10

Edd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!