Hey Irfaan, JUnit is an open source unit testing tool and used to test small/large units of code. To run the JUnit test you don’t have to create a class object or define the main method. Junit provides assertion library which is used to evaluate the test result. Annotations of JUnit are used to run the test method. JUnit is also used to run the Automation suite having multiple test cases.
It is used by developers to implement unit testing in Java, and accelerate programming speed and increase the quality of code. JUnit test framework provides the following important features:
- Fixtures: Fixed state of a set of objects used as a baseline for running tests. The purpose of a test fixture is to ensure that there is a well-known and fixed environment in which tests are run so that results are repeatable.
- Test suites: Bundles a few unit test cases and runs them together. Both @RunWith and @Suite annotation are used to run the suite test.
- Test runners: Test runner is used for executing the test cases.
- JUnit classes: JUnit classes are important classes, used in writing and testing JUnits. Some of the important classes are Assert, TestCase, TestResult.