Improve functionality of JAVA application by testing with JUnit.
As stated in my previous post, Unit Testingis mainly focused on testing of each smallest logical unit of your Java/J2EE application. This unit may be a module, a package, a class or a file. Java Unit Testing includes generating test classes for your source code and executing it with different parameters to ensuring that your source code module works fine in all possible conditions.
JUnit is a unit testing framework for the Java programming language. Itprovides tools to structure your test cases and run them. A test case is a document which describes an input, action, or event and an expected response in defined scenario, to determine whether an application is working properly or not. JUnit calls one test method which may comprise multiple test cases.
The test development process includes:-
• Write failing test first.
• Write enough code to pass.
• Refactor.
• Run tests again.
• Repeat until software meets goal.
• Write new code only when test is failing.
Junit is one of the best technique to Separate production and test code but typically in the same packages. It even Allow to write code faster while increasing quality of the program. Some of the features of Junit are:-
• Check its own results and provide immediate feedback to the user.
• Tests written are inexpensive.
• Increases the stability of software product.
• Written in Java
• Freeware
Hence, one can build a bright future using the techniques of Junit.