Example
Here are the steps to generate test skeleton for existing code:
- Open Eclipse, and choose the project you want to create test cases for
- In the Package Explorer, select the java class you want to generate the Junit test for
- Go to File -> New -> Junit Test Cases
- Change the Source folder to point to the test using Browse (Note: It is better to separate the source code from the testing code)
- Change the Package based on the destination package you want
- In the Class under test, make sure you enter the class you want to generate the test cases for.
- Click Next
- Select the methods you want to test for
- Click Finish
Now, you will have a Junit class generated for testing the source class you have