On Fri, 6 Mar 2026 10:50:55 GMT, Alan Bateman <[email protected]> wrote:

>> A migration from TestNG to JUnit
>
> test/jdk/java/util/Arrays/AsList.java line 44:
> 
>> 42: import org.junit.jupiter.params.provider.MethodSource;
>> 43: 
>> 44: @TestInstance(TestInstance.Lifecycle.PER_CLASS)
> 
> Just curious why this is needed as the method source is a static method.

This test was converted by an automated tool, and this line was added by it.
I agree that it is not that useful in _this_ case, but doesn't seem to hurt 
either.

> test/jdk/java/util/Arrays/AsList.java line 60:
> 
>> 58:                 itr.remove();
>> 59:                 fail("Remove must throw");
>> 60:             } catch (UnsupportedOperationException ex) {
> 
> I assume a deeper migration would change this to 
> `assertThrows(UnsupportedOperationException.class, itr::remove)`.

Yes.

> test/jdk/java/util/Arrays/AsList.java line 64:
> 
>> 62:             }
>> 63:         }
>> 64:         assertFalse(itr.hasNext());
> 
> In passing, I assume this assertFalse is redundant as it is checked in the 
> loop.

I see it as redundant as well, but it is harmless.

> test/jdk/java/util/Arrays/largeMemory/ParallelPrefix.java line 160:
> 
>> 158:         int[] parallelRangeResult = Arrays.copyOfRange(data, fromIndex, 
>> toIndex);
>> 159:         Arrays.parallelPrefix(parallelRangeResult, op);
>> 160:         assertArraysEqual(parallelRangeResult, 
>> Arrays.copyOfRange(sequentialResult, fromIndex, toIndex));
> 
> With JUnit, the first parameter to assertArraysEqual is the "expected" as 
> migration from TestNG will usually means transposing these parameters. It's 
> really only an issue if there is failure of course, and only leads to a 
> confusing message.

The `assertArraysEqual()` in this class are _not_ JUnit methods. It's their 
implementations that eventually invoke the real JUnit method, with `expected` 
and `actual` in the conventional JUnit order.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/30111#discussion_r2895292207
PR Review Comment: https://git.openjdk.org/jdk/pull/30111#discussion_r2895292594
PR Review Comment: https://git.openjdk.org/jdk/pull/30111#discussion_r2895294969
PR Review Comment: https://git.openjdk.org/jdk/pull/30111#discussion_r2895296549

Reply via email to