Junit testing framework

Junit is a unit test framework for implementing testing in java. However it is suitable for unit testing but for integration testing you should use TestNG framework instead of it.

Why use a testing framework?

Using a testing framework is beneficial because it forces you to explicitly declare the expected results of specific program execution routes. When debugging it is possible to write a test which expresses the result you are trying to achieve and then debug until the test comes out positive. By having a set of tests that test all the core components of the project it is possible to modify specific areas of the project and immediately see the effect the modifications have on the other areas by the results of the test, hence, side-effects can be quickly realized.
JUnit promotes the idea of first testing then coding, in that it is possible to setup test data for a unit which defines what the expected output is and then code until the tests pass. It is believed by some that this practice of "test a little, code a little, test a little, code a little..." increases programmer productivity and stability of program code whilst reducing programmer stress and the time spent debugging


Features
  1. JUnit is an open source framework for unit testing in java.
  2. It has annotation to identify and control test methods.
  3. It has assertions for testing expected results.
  4. It has Test Runner to drive tests methods.
  5. JUnit tests allow you to write code faster which increasing quality
  6. JUnit tests can be run automatically and they check their own results and provide immediate test result. It automatically generate report of test results no need to manually analyze.
  7. JUnit tests can be clubbed into test suites containing test methods or test suite.
What is a Unit Test Case?

A Unit Test Case is a part of code which ensures that another part of code (method) works as expected. To achieve those desired results quickly, test framework is required .JUnit is perfect unit test framework for java programming language.
A formal written test-case is characterized by a known input and by an expected output, which is worked out before the test is executed. The known input should test a precondition and the expected output should test a post condition.
There must be at least two test cases for each requirement: one positive test and one negative test. If a requirement has sub-requirements, each sub-requirement must have at least two test cases as positive and negative.

No comments:

Post a Comment

Leave your comments, queries, suggestion I will try to provide solution