Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run unit tests for just the source files which have changed?

Is there a way I can get ant to run the unit tests just for the java classes it builds? For example, if MyClass.java is out of date, ant will build MyClass.class. After that I want it to also run MyClassTest and MyClassTestSuite if they exist. It doesn't have to be based on a naming convention. I'd be fine with using annotations or any other method that works.

EDIT: Several people have chimed in saying this is a bad idea. It would be, if I planned on checking in without running all of our unit tests. My main project has over 16k unit tests which take about 20 minutes to run. I'll run them all before check-in, but it's completely impractical to run the whole suite every time I change a file. Sorry, I should have given more context.

like image 706
Craig P. Motlin Avatar asked Jun 24 '09 20:06

Craig P. Motlin


1 Answers

I would not recommend this approach, There is a good chance of missing errors introduced by side effects.

like image 102
Ramon Avatar answered Sep 22 '22 10:09

Ramon