Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create junit automatically [closed]

Tags:

java

junit

jboss

Is there any way that i need not write junit test cases and it gets generated automatically.

Actually i have an application which is fully tested but has no junit written for it. So i am sure that it is complete and has not much error. But my client wants a code coverage report for the same.

Is there any tool available which can generate test cases automatically.

I am using java, jboss portal.

like image 675
Varun Avatar asked May 29 '12 06:05

Varun


People also ask

Can we automate JUnit?

JUnit is best at creating repeatable test cases. If there is a need to run a test in JUnit 100 times, one doesn't need to write it 100 times or not even execute it manually 100 times. This process is automated. Automation testing is usually preferred over manual testing because of faster and reliable results.

How do I run JUnit tests automatically?

To run JUnit 5 tests from Java code, we'll set up an instance of LauncherDiscoveryRequest. It uses a builder class where we must set package selectors and testing class name filters, to get all test classes that we want to run.

How do I create a JUnit test case automatically in Intellij?

Right-click the test root folder or package in the test root folder in which you want to create a new test and select New | Java Class. Name the new class and press Enter . Press Alt+Insert and select Test Method to generate a new test method for this class. Name the new method and press Enter .


1 Answers

Writing the unit tests for the sake of writing or for coverage is a bad idea. Unit tests should be written to actually test your code. In your situation you could start writing the tests for the more important classes first and then gradually work towards increasing the code coverage. You might even find some real bugs in this process.

like image 94
Kuldeep Jain Avatar answered Oct 29 '22 16:10

Kuldeep Jain