This section contains the introduction to JUnit.
What is JUnit
JUnit is a unit testing open source framework to write and run repeatable tests for the Java programming language. JUnit was originally written by Erich Gamma and Kent Beck. It is part of unit testing frameworks family collectively known as xUnit. Other examples are CPPUnit, PHPUnit, JSUnit etc.
JUnit is linked as a JAR at compile-time; the framework resides under packages junit.framework for JUnit 3.8 and earlier and under org.junit for JUnit 4 and later.
JUnit has now become the standard tool for Test-Driven Development in Java. JUnit test generators now part of many Java IDEs (Eclipse, BlueJ, Jbuilder, DrJava etc).
Testing through JUnit
You can test JUnit by using Test Case & Test Suit . But the question arise in your mind is what is a Test Case & Test Suit. Given below it's description :
Test Case: A Test Case is a java class which is used to test a single class.
Test Suite :A Test Suit is a java class which contains many test cases or java classes to test together in a single run.
We will describe Test Case & Test Suite later. The advantages & disadvantages of Test Case & Test Suit are given below :
Advantages of Test cases & Test Suite
-
Reduces total number of bugs in delivered code.
-
Makes code much more maintainable and refactorable.
Disadvantages of Test cases & Test Suite
-
It?s a lot of extra programming. - True, but use of a good test framework can help quite a bit.
-
You don?t have time to do all that extra work - False! Experiments repeatedly show that test suites reduce debugging time more than the amount spent building the test suite.
[ 0 ] Comments