In
this tutorial series, you are going to learn about junit.
What is junit?
It
is an open source unit testing library written in Java.
I
am going to use below maven dependency throughout the tutorial.
<!-- https://mvnrepository.com/artifact/junit/junit
-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
- Setting up junit project in eclipse
- Hello World program
- @Test annotation
- @Test: Test the exception
- Test exception message
- Fail the test case based on execution time
- Run the test from main method
- Aggregating tests in a suite
- @RunWith: Run the tests with this class
- Assertions
- assert methods
- Assert Boolean values
- Failing the test case
- Asserting equality, not equality checks
- Assert null values
- Assert object reference equality, not equality
- Assert by matcher
- Assumptions
- Categorising test cases
- Working with text fixtures @Before, @After, @BeforeClass, @AfterClass
- @Ignore: Ignoring tests
- parameterized tests
- Rules
- ExpectedException rule: check the method is throwing specific exception
- ErrorCollector: Continue test execution even after failure
- TemporaryFolder rule
- @Timeout rule: Time out for all unit tests
- TestName rule: get the test case name under execution
- ExternalResource rule
- Create custom rules
- @ClassRule annotation
- @RuleChain: Ordering junit rules
- Ordering test cases execution
- Theories
- Theories: @TestedOn annotation
- @TestedOn annotation
No comments:
Post a Comment