[FLINK-39769][tests][JUnit5 migration] Module: flink-examples-streaming#28496
[FLINK-39769][tests][JUnit5 migration] Module: flink-examples-streaming#28496spuru9 wants to merge 2 commits into
Conversation
|
cc: @raminqaf @snuyanzin Can you review this PR as well on JUnit5 migration. |
| @Parameter private boolean asyncState; | ||
|
|
||
| @Parameterized.Parameters | ||
| public static Collection<Boolean> setup() { | ||
| return Arrays.asList(false, true); | ||
| @Parameters(name = "asyncState: {0}") | ||
| public static List<Boolean> parameters() { | ||
| return List.of(false, true); | ||
| } | ||
|
|
There was a problem hiding this comment.
why do we need it?
can we just use
@ParameterizedTest
@Values(true, false)?
same for others
…examples-streaming Migrate the remaining JUnit 4 tests in flink-examples-streaming to JUnit 5: - StreamingExamplesITCase and SocketWindowWordCountITCase: replace @RunWith(Parameterized.class) with native JUnit 5 @ParameterizedTest + @valuesource on the tests that read asyncState, and move the base class from AbstractTestBaseJUnit4 to AbstractTestBase. In StreamingExamplesITCase the two tests that don't use asyncState become plain @test. - TopSpeedWindowingExampleITCase: drop TestLogger and replace the @ClassRule MiniClusterWithClientResource / TemporaryFolder with @RegisterExtension MiniClusterExtension and @tempdir. - Convert the remaining org.junit.Assert.fail to AssertJ.
|
Done — switched both to native |
|
|
||
| /** Tests for {@link TopSpeedWindowing}. */ | ||
| public class TopSpeedWindowingExampleITCase extends TestLogger { | ||
| class TopSpeedWindowingExampleITCase { |
There was a problem hiding this comment.
why logger just disapeared?
There was a problem hiding this comment.
Fixed. Added the extension file taking reference from #19716,
Didnt add test-jar exclude, nothing consumes this module's test-jar, let me know if we want to add it for caution or another reason.
…for flink-examples-streaming Restores per-test logging after dropping `extends TestLogger` in the JUnit5 migration; matches the pattern used by other migrated modules. No test-jar exclude needed since this module's test-jar is not consumed elsewhere.
What is the purpose of the change
Migrate the remaining JUnit 4 tests in
flink-examples/flink-examples-streamingto JUnit 5 (Jupiter). After this PR the module has zero JUnit 4 imports. Part of the umbrella JUnit 4 → 5 migration.JIRA: FLINK-39769 (sub-task of FLINK-25325)
Brief change log
Three test classes migrated:
StreamingExamplesITCaseandSocketWindowWordCountITCase(parameterized onasyncState):@RunWith(Parameterized.class)→ native JUnit 5@ParameterizedTest+@ValueSource(booleans = {false, true}); the boolean arrives as a method argument rather than an injected field.StreamingExamplesITCase, onlytestWindowWordCountandtestWordCountactually readasyncState, so only those are parameterized;testWindowJoinandtestSessionWindowingbecome plain@Testinstead of running redundantly under both values.extends AbstractTestBaseJUnit4→extends AbstractTestBase(the JUnit 5 sibling).org.junit.Assert.fail→org.assertj.core.api.Assertions.fail(SocketWindowWordCountITCase).TopSpeedWindowingExampleITCase:@ClassRule MiniClusterWithClientResource→@RegisterExtension static MiniClusterExtension.@ClassRule TemporaryFolder→@TempDir static File;newFile()/newFolder()→new File(tempDir, ...).extends TestLogger;org.junit.Test→org.junit.jupiter.api.Test.publicon test classes and methods per the Flink JUnit 5 Migration Guide.No production code is touched.
Verifying this change
This change is a test-only migration covered by the existing tests it migrates:
Result: 9 tests run, 0 failures, 0 errors, 0 skipped (
StreamingExamplesITCase6,SocketWindowWordCountITCase2,TopSpeedWindowingExampleITCase1).StreamingExamplesITCaseruns 6 rather than the previous 8:testWindowJoinandtestSessionWindowingnever readasyncState, so they no longer execute once per value. No coverage is lost — the dropped runs were identical.Does this pull request potentially affect one of the following parts:
@Public(Evolving): (no)Documentation
Was generative AI tooling used to co-author this PR?