Create junit automatically [closed]

2020-06-16 02:35发布

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.

标签: java jboss junit
5条回答
Deceive 欺骗
2楼-- · 2020-06-16 03:12

Check Google's CodePro Analytix. It even has options to generate test cases with mocks. There is also an eclipse plugin. http://code.google.com/javadevtools/codepro/doc/features/junit/test_case_generation.html

查看更多
SAY GOODBYE
4楼-- · 2020-06-16 03:18

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.

查看更多
别忘想泡老子
5楼-- · 2020-06-16 03:26

Randoop is the framework you need https://randoop.github.io

查看更多
趁早两清
6楼-- · 2020-06-16 03:27

I do agree that generating tests is definitely not the way to go, but may be the starting point for writing real tests. careful: CodePro generates really silly tests sometimes! But when you say your code is fully tested then I assume that you have written some sort of main-method that is doing all the testing stuff. Generating test reports for these main-method-based-tests would be similar to JUnit test coverage reporting. For example by using cobertura, you first instrument your compiled classes, start your test-main methods and examine the generated coverage-report-files with "sonar" for example.

The same should work if you manually test your application use case for use case. But in this case I would strongly suggest to automate these tests at least with some tool like selenium etc.

查看更多
登录 后发表回答