Code Robo
Virtual Service
Java Code Complience

Generate JUnit Test Cases
       Talk to EasyAssistant

For any Java/J2EE project we wirte lot many java classes. To do the unit test of those Java classes normally we used to write JUnit test cases. Here we have online Junit Tool to generate JUnit test cases for each java class.. Generating Junit testcases common requirement in any Java/J2EE development project.Take Java Code as input and generate JUnit test class as output.

This tool supports following important features:
  • Test suites
  • Test runners
  • JUnit classes
  • Supports both JUnitVersion 4.0 and Version 5.0
Gnerated code uses following classes:
  • Assert - Contains assert methods.
  • TestCase - defines the fixture to run multiple tests.
  • TestResult - Collect the results of executing a test case.
Java Code.(* Required): It is required.
Ignore Private Methods JUnit Version :        JUnit 4.0 JUnit 5.0

How It Works:
First format the java source code and then parse it. Extract the tokens. Generate JUnit class and add a test method for each non-private methods. Equate the actual and expeted value. If expected and actual value does not match, it fail the test cases. It generate code to handle exception and fail the test case if there is any exception.
. Input Parameters are:
  1. Java Code - Which is used to generate the JUnit test cases
  2. Generate Test Cases For Private Methods - Generate unit test cases for private method
  3. Click on the button 'Generate JUnit '
User Comments:
Very useful tool!
easycodeforall: (2022-04-21)
Thank you so much!

Arvind Sharma(2022-04-16):
Great tool!!!!! Made the unit testing easy!!!!!!!!!!
easycodeforall(admin): (2022-04-21)
Thanks for using

Shefali Chadha(2022-04-16):
Can I generate JUnit test case for a single method only?
easycodeforall(admin): (2022-04-21)
You can generate a JUnit test case for a single method. But in the generated JUNit code there will be a default JAVA class name.

Prathibha Maheshwari(2022-04-16):
Is there a way to generate two test methods for a single java public method in a class?
easycodeforall(admin): (2022-04-21)
At present it will generate only one test method per method. It does not support more than one test method per method. If you can let us know more about your requirement details, we may think of adding this feature in future. Thanks for using easycodeforal !.

It's not generating test method correctly for following cases. After code generation maual modification is required.
//---------------------------------------------------------// public void senMsg(Exception ex, List authList) { System.out.println("---------------------"); } //---------------------------------------------------------//
upgrade to Junit5 please
easycodeforall: (2022-04-21)
Thanks for using easycodeforall and puting a enhanancement request.! We will start supporting Junit5 soon.
easycodeforall: (2022-04-21)
We have added JUnit 5 features. JUnit Code can be generate for both JUnit version 4.0 and 5.0

Post Your Comment:
Name :
Email ( Optional) :
Comments / Suggestion (* Required) It is required: :