Repository navigation
Port CombinePerKeyExamplesTest off DoFnTester - #41728
harshilv17 wants to merge 1 commit into
Conversation
Run ExtractLargeWordsFn and FormatShakespeareOutputFn in a TestPipeline and check their output with PAssert, like BigQueryTornadoesTest. The assertions now check the exact output instead of only that it contains each expected element. The PTransform style guide still recommended DoFnTester for unit testing DoFns; point it at TestPipeline and PAssert instead. Fixes apache#41727
There was a problem hiding this comment.
📋 Review Summary
This PR cleanly migrates CombinePerKeyExamplesTest off the deprecated DoFnTester onto TestPipeline and PAssert, while tightening the test assertions to verify exact output elements using containsInAnyOrder. It also updates the PTransform style guide documentation to reflect current Beam testing best practices.
🔍 General Feedback
- The migration to
TestPipelineandPAssertfollows standard Apache Beam testing patterns and matches neighboring cookbook tests. - Replacing individual
hasItemchecks withPAssert.that(...).containsInAnyOrder(...)improves test coverage by ensuring filtered elements (such as short words) are not unexpectedly emitted.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
|
Assigning reviewers: R: @Abacn for label java. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
Fixes #41727, a subtask of #18687.
Ports
CombinePerKeyExamplesTestoff the deprecatedDoFnTester:ExtractLargeWordsFnandFormatShakespeareOutputFnnow run in aTestPipelinewithPAssert, the same wayBigQueryTornadoesTestnext to it does. The assertions now check the exact output (containsInAnyOrder) rather thanhasItemfor each expected element, so an extra output, such as a word shorter thanMIN_WORD_LENGTH, would now fail the test.The PTransform style guide still recommended
DoFnTesterfor unit testingDoFns; it now points atTestPipelineandPAssert.CombineFnTesterandSourceTestUtilsare unchanged.Ran
CombinePerKeyExamplesTestlocally with JDK 17 (both pass);spotlessCheckandcheckstyleTestare clean. Adding an unexpected element to the expected output makestestExtractLargeWordsFnfail.Fixes #41727).CHANGES.md: not needed, test and doc change only.