RFR: 8301701 : java/net/DatagramSocket/DatagramSocketMulticasting.java should be hardened [v2]
Darragh Clarke
duke at openjdk.org
Tue Feb 14 15:42:29 UTC 2023
On Tue, 14 Feb 2023 15:39:27 GMT, Christian Stein <cstein at openjdk.org> wrote:
>> test/jdk/java/net/DatagramSocket/DatagramSocketMulticasting.java line 66:
>>
>>> 64: import static org.junit.jupiter.api.Assumptions.assumeTrue;
>>> 65:
>>> 66: @TestInstance(TestInstance.Lifecycle.PER_CLASS)
>>
>> Is this needed?
>
> I don't think so.
>
> One test instance per test class is useful for when having multiple test methods that want to share state in instance fields. Here, we have a single test method and no shared state.
>
> Find details at https://junit.org/junit5/docs/current/user-guide/#writing-tests-test-instance-lifecycle
>> If you would prefer that JUnit Jupiter execute all test methods on the same test instance, annotate your test class with `@TestInstance(Lifecycle.PER_CLASS)`. When using this mode, a new test instance will be created once per test class. Thus, if your test methods rely on state stored in instance variables, you may need to reset that state in `@BeforeEach` or `@AfterEach` methods.
It isn't, I'll clean that up
-------------
PR: https://git.openjdk.org/jdk/pull/12513
More information about the net-dev
mailing list