Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse: how to update a JUnit test file with newly added method in the source file?

Using Eclipse (Helios), I could create a JUnit test file ClassATest.java of the source file ClassA.java by using New -> JUnit Test Case -> Class under test..., then choose all the methods of ClassA to be tested.

If later we add some more methods to ClassA, how do we easily reflect this addition in ClassATest ? (No copy/paste plz).

like image 866
CuongHuyTo Avatar asked Aug 24 '11 14:08

CuongHuyTo


1 Answers

One solution is to use MoreUnit

With MoreUnit installed to Eclipse, one can right click onto the newly added method (and not yet unit tested), and choose "Generate Test"

Of course, if one always follows the writing-test-before-writing-method style, then this solution is not needed. However in reality sometimes you don't have a clear idea of what you would want to do, in that case you would have to code up some method, play with it, then rethink and code again until you are satisfied with the code and want to make it stable by adding unit test.

like image 66
CuongHuyTo Avatar answered Oct 22 '22 13:10

CuongHuyTo