Difference between JUnit and xUnit

JUnit is a  unit testing framework for the Java Programming Language                         

 JUnit has been important in the development of test driven development and is one of a family of unit testing frameworks which is collectively known as xUnit that originated with SUnit


Software used to systematically run reproducible tests on a piece of software under test is known as a test harness; part of its job is to set up suitable test fixtures.

Test fixture in xUnit

In generic xUnit, a test fixture is all the things that must be in place in order to run a test and expect a particular outcome.
Frequently fixtures are created by handling setUp() and tearDown() events of the unit testing framework. In setUp() one would create the expected state for the test, and in tearDown() it would clean up what had been set up.
Four phases of a test:
  1. Set up -- Setting up the test fixture.
  2. Exercise -- Interact with the system under test.
  3. Verify -- Determine whether the expected outcome has been obtained.
  4. Tear down -- Tear down the test fixture to return to the original state.
JUnit is linked as a JAR at compile-time; the framework resides under package junit.framework for JUnit 3.8 and earlier, and under packageorg.junit for JUnit 4 and later.


A JUnit text fixture is a Java object. With older versions of JUnit, fixtures had to inherit from junit.framework.TestCase

Test methods must be annotated by the @Test annotation. If the situation requires ,it is also possible to define a method to execute before (or after) each (or all) of the test methods with the@Before (or @After) and @BeforeClass (or @AfterClass) annotations.