• S
    Migrate parameterized tests in spring-core · 3df85c78
    Sam Brannen 提交于
    This commit migrates parameterized tests in spring-core using the
    "composed @ParameterizedTest" approach. This approach is reused in
    follow-up commits for the migration of the remaining modules.
    
    For a concrete example, see AbstractDataBufferAllocatingTests and its
    subclasses (e.g., DataBufferTests).
    
    Specifically, AbstractDataBufferAllocatingTests declares a custom
    @ParameterizedDataBufferAllocatingTest annotation that is
    meta-annotated with @ParameterizedTest and
    @MethodSource("org.springframework.core.io.buffer.AbstractDataBufferAllocatingTests#dataBufferFactories()").
    
    Individual methods in concrete subclasses are then annotated with
    @ParameterizedDataBufferAllocatingTest instead of @ParameterizedTest or
    @test.
    
    The approach makes the migration from JUnit 4 to JUnit Jupiter rather
    straightforward; however, there is one major downside. The arguments
    for a @ParameterizedTest test method can only be accessed by the test
    method itself. It is not possible to access them in an @BeforeEach
    method (see https://github.com/junit-team/junit5/issues/944).
    Consequently, we are forced to declare the parameters in each such
    method and delegate to a custom "setup" method. Although this is a bit
    cumbersome, I feel it is currently the best way to achieve fine grained
    parameterized tests within our test suite without implementing a custom
    TestTemplateInvocationContextProvider for each specific use case.
    
    Once https://github.com/junit-team/junit5/issues/878 is resolved, we
    should consider migrating to parameterized test classes.
    
    See gh-23451
    3df85c78
ServerSentEventHttpMessageWriterTests.java 8.6 KB