JUnit, an open-source testing framework available in Java Programming Language. Testing is an important phase in the Software Development Process which helps to identify the bug and error in the system. Various Kinds of testing framework available in the market and Junit is one of them.

JUnit belongs to the family of unit testing frameworks collectively known as Xunit, which originated with JUnit. Currently, Junit5 is available in the market. Junit is performed by creating a test case, which ensures the correctness of logic or code. It uses org.junit packages from where many interfaces and classes for Junit testing like Assert, Test, Before, After, etc.

Junit testing is also divided into two:

Manual Testing: It is a type of testing where test cases manually executed without any tool support.

Automated Testing: It is a type of testing done by taking tool support and executing the test cases by using an automation tool in Automated testing.

Advantage of Testing:

  • A simple framework for writing automated, self-verifying tests in Java
  • Support for test assertions
  • Test suite development
  • Immediate test reporting
  • Help to implement the theory of Test before you code.

Disadvantage of Testing:

  • It cannot do dependency testing as opposed to the TestNG framework.
  • It’s not suitable for higher-level testing i.e. for large test suites.
  • Group testing cannot be done in JUnit, which is available in TestNG.
  • Can’t create HTML reports of test cases.

Some Default Method of Junit:

Before you go for testing, the Developer must know the default inbuilt function provides by the JUnit, some of them are given below:

  1. void assertEquals(boolean expected, boolean actual): checks that two primitives/objects are equal. It is overloaded.
  2. void assertTrue(boolean condition): checks that a condition is true.
  3. void assertFalse(boolean condition): checks that a condition is false.
  4. void assertNull(Object obj): checks that the object is null.
  5. void assertNotNull(Object obj): checks that the object is not null.