The main framework for testing Java code is JUnit.
Junit has gone through several versions.
- As of W21, programming assignments for
Menuwere based on JUnit 4.
- However, Spring Boot legacy code projects are using JUnit 5.
Eventually, the programming assignments for
Menu will be updated to use JUnit 5 syntax, but for now, it’s helpful to be aware of the differences.
The import statements for JUnit 4 look like these (taken from the
import org.junit.Test; import org.junit.Before; import static org.junit.Assert.assertEquals;
The import statements for JUnit 5 in a Spring Boot projects look like these:
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import org.junit.jupiter.api.Test;
This article explains the difference: https://www.baeldung.com/junit-assert-exception