RFR: 8304014: Convert test/jdk/java/util/zip/ZipFile/CorruptedZipFiles.java to junit [v3]

Daniel Fuchs dfuchs at openjdk.org
Wed Mar 29 18:31:25 UTC 2023


On Wed, 29 Mar 2023 18:15:42 GMT, Eirik Bjorsnos <duke at openjdk.org> wrote:

>> CorruptedZipFiles could benefit from some spring cleaning and a conversion to testNG:
>> 
>> - The actual tests are moved into their own `@Test` methods, given more meaningful names and a Javadoc comment explaining the constraint being verified
>> - The setup code is moved to a `@Before` method, slightly modernized and rewritten to take advantage of `assertEquals` 
>> - `checkZipExceptionImpl` is updated to take advantage of `expectThrows`
>> - A bunch of constants copied over from `ZipFile` can be deleted since JDK-6225935 has long been fixed
>
> Eirik Bjorsnos has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Junit version

Hi Eirik, thanks for following up on my suggestion :-)

test/jdk/java/util/zip/ZipFile/CorruptedZipFiles.java line 36:

> 34: import org.junit.BeforeClass;
> 35: import org.junit.Test;
> 36: 

I believe you should be using corresponding annotations from `org.junit.jupiter.api` instead.
>From https://junit.org/junit5/docs/current/user-guide/index.html#migrating-from-junit4
> `@Before` and `@After` no longer exist; use `@BeforeEach` and `@AfterEach` instead.
> `@BeforeClass` and `@AfterClass` no longer exist; use `@BeforeAll` and `@AfterAll` instead.

Similarly the `@Test` annotation should be imported from `org.junit.jupiter.api`

-------------

Changes requested by dfuchs (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/12563#pullrequestreview-1363720139
PR Review Comment: https://git.openjdk.org/jdk/pull/12563#discussion_r1152333259


More information about the core-libs-dev mailing list