Is there any automated testing tool or framework which will test our Java code without writing any piece of code in test cases from developer view?
-
Do you mean a testing tool that will test code without being given any code to test? – Anderson Green Jan 16 '13 at 07:20
3 Answers
There's a tool called javac
which will run some rudimentary tests on your code.
For example, if your code is missing a }
, it will tell you. Also, it will detect when you try to call a function with the wrong type of argument, or call a function that doesn't exist.
You may find FindBugs useful, since it can warn about potentially dangerous code, but it has a lot of false positives.
Beyond that, what you're asking for is some sort of programmer AI. If the computer could tell that you've implemented your code correctly, why not just have the computer write it for you?

- 53,280
- 21
- 146
- 188
-
2Random Code Generator + Automated Testing Tool = Effortless Success! I like it a lot! – emory Apr 14 '12 at 06:37
You can consider static code analysis tools such as Coverty or FindBugs, which will try to find potential bugs just based on the source code without actually executing it.
You can also try randoop, which automatically generates random JUnit test cases (random sequences of method calls) looking for object contract violations. It discards method sequences that result in illegal argument exceptions and such, which is a nice positive. It also remembers method sequences that construct complex objects, and sequences that result in contract violations.
If your code has specification written in JML, ESC/Java by Compaq can verify your code against those.

- 10,323
- 4
- 46
- 76