On Tue, 30 Dec 2025 11:39:27 GMT, Michael McMahon <[email protected]> wrote:

>>> Could you remove the `TestInstance.Lifecycle.PER_CLASS` annotation from 
>>> other tests as well?
>> 
>> Yes, that should be do-able.
>
>> > Could you remove the `TestInstance.Lifecycle.PER_CLASS` annotation from 
>> > other tests as well?
>> 
>> Yes, that should be do-able.
> 
> Actually, it doesn't seem to be possible to remove them all. You have to make 
> the method static to remove the annotation, but in some cases then the test 
> passes but is not being executed with the following warning.
> 
> Dec 30, 2025 11:36:46 A.M. 
> org.junit.platform.launcher.core.DiscoveryIssueNotifier logIssues
> WARNING: TestEngine with ID 'junit-jupiter' encountered a non-critical issue 
> during test discovery:
>         
> (1) [WARNING] @Test method 'public static void 
> DateFormatterTest.testDateFormat() throws java.lang.Exception' must not be 
> static. It will not be executed.
>     Source: MethodSource [className = 'DateFormatterTest', methodName = 
> 'testDateFormat', methodParameterTypes = '']
>             at DateFormatterTest.testDateFormat(SourceFile:0)
>         
> [ JUnit Containers: found 3, started 3, succeeded 3, failed 0, aborted 0, 
> skipped 0]
> [ JUnit Tests: found 0, started 0, succeeded 0, failed 0, aborted 0, skipped 
> 0]
>         
> STATUS:Passed.
> 
> I'm questioning the wisdom of removing the annotation at all now ....

as far as I can tell, we only need to change the provider methods and the 
beforeAll/afterAll methods to static in order to remove the annotation. The 
test methods must not be static.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28908#discussion_r2652911132

Reply via email to