Tagged: junit

0

Better unit test with JUnit 5 Parameterized Tests

In many situations, you have to write unit tests that are identical, with the exception of the input or possibly the expected value. It is tempting to write the same test multiple times or to write one test with the dynamic part in a loop. JUnit 5, however, offers a better option with the @ParametrizedTest annotation that allows you to have one test, but with different inputs and expected values. Let’s take a look. Importing the library into your project...

0

Writing unit tests in Java using jUnit and Mockito

Testing is important for all software systems and applications. It will help you easily find bugs and it will prevent crashes and downtimes for your application, especially if the system evolves over time. At first it may not seem critical, but as the system grows and becomes more complex, the likelihood of a bug appearing without being noticed grows. There are multiple testing frameworks available for Java, with jUnit being one of the most widely used. In this article, we...