Upgrade JUnit4 tests to JUnit5 #874
Comments
While migrating from JUnit 4 to 5, I ran into a small issue... The alternative is that I add a wrapper to the plain assertThrows in our custom Assert. However, we will still import things like AssertEquals or AssertTrue from JUnit, which becomes the same problem as above. Any suggestions? |
Looking through git blame for existing Assert class, |
Does the following
|
Nope, |
Additionally, I was thinking of migrating to JUnit 5.4.0. It's currently on release candidate, hopefully in a couple of weeks when I finish migrating everything it will become stable... |
If possible, I'd like to unify our use of |
Haha I just realized, actually, this design is consistent with the rest of the
Yes, good line of thought 👍
If I'm reading rightly, I think this is a non-issue, since the current code base also uses custom I think your suggestion helps to improve clarity in addressing the issue of "why are we importing assertThrows from 2 places?" We can write header comments to explain that we are wrapping the |
Yes, that was one qualm I had when I did AddressBook for my CS2103T. I'm definitely going to look into how we can unify these two things.
Yea, this sounds good. |
Our tests use JUnit4. Let's upgrade them to use JUnit5 instead.
org.junit.jupiter.api.Test
instead oforg.junit.Test
)Test
being used for specifying expectations. We use this tospecify timeout in
PersonListPanelTest
. Instead we should now useassertTimeoutPreemptively
@Before
to@BeforeEach
@After
to@AfterEach
@BeforeClass
to@BeforeAll
@AfterClass
to@AfterAll
assertAll
for related assertions@Rule
and@ClassRule
. Instead, we need to@ExtendWith
, which generally requires creating an extension class.Mentor: @Zhiyuan-Amos
Assigned to: @sijie123
The text was updated successfully, but these errors were encountered: