JUnit
JUnit is a framework for writing unit tests both in Java and in Android. It is responsible for how tests are executed, allowing developers to configure their tests. It offers a multitude of features, such as the following:
- Setup and teardown: These are called before and after each test method is executed, allowing developers to set up relevant data for the test and clear it once the test is executed. They are represented by the
@Before
and@After
annotations. - Assertions: These are used to verify the result of an operation against an expected value.
- Rules: These allow developers to set up inputs that are common for multiple tests.
- Runners: Using these, you can specify how the tests can be executed.
- Parameters: These allow a test method to be executed with multiple inputs.
- Orderings: These specify in which order the tests should be executed.
- Matchers: These allow you to define patterns that can then be used to validate the results of the...