Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting JUnit "tests" that never assert anything

Tags:

junit

assert

We used to have a technical director who liked to contribute code and was also very enthusiastic about adding unit tests. Unfortunately his preferred style of test was to produce some output to screen and visually check the result.

Given that we have a large bank of tests, are there any tools or techniques I could use to identify the tests never assert?

like image 755
Rob Oxspring Avatar asked Oct 05 '22 05:10

Rob Oxspring


1 Answers

Since that's a one time operation I would:

  • scan all test methods (easy, get the jUnit report XML)
  • use an IDE or other to search references to Assert.*, export result as a list of method
  • awk/perl/excel the results to find mismatches

Edit: another option is to just look for references to System.out or whatever his preferred way to output stuff was, most tests won't have that.

like image 62
ptyx Avatar answered Oct 10 '22 04:10

ptyx