DEV Community

Discussion on: Junit 5 Tutorial for Beginners

Collapse
 
mohdfarhankazi profile image
mohdfarhankazi

Post is very good and informative. I spent considerable time and practiced on its examples. Thanks. But I found some mistakes in coding examples snippets. I am listing it in following.

1) Implementing Lifecycle Annotations in our Test
@BeforeAll and @AfterAll

In this section you are creating instance of ContactManager in 3 test methods which are shouldThrowRuntimeExceptionWhenFirstNameIsNull(), shouldThrowRuntimeExceptionWhenLastNameIsNull and shouldThrowRuntimeExceptionWhenPhoneNumberIsNull. This is not required because You already created instance
in setup method marked with @BeforeAll annotation

2) Parameterized Tests

You gave example of Paramterized test for method source using annotation @MethodSource. Here you using instannce method which name phoneNumberList. I think it should be static. I tried with instance but would fail untill I did not make it static.

Again Thanks for such great tutorial.