diff --git a/scio-test/src/test/scala/com/spotify/scio/testing/PipelineTestUtilsTest.scala b/scio-test/src/test/scala/com/spotify/scio/testing/PipelineTestUtilsTest.scala index 701d1f7af4..71d40dbee3 100644 --- a/scio-test/src/test/scala/com/spotify/scio/testing/PipelineTestUtilsTest.scala +++ b/scio-test/src/test/scala/com/spotify/scio/testing/PipelineTestUtilsTest.scala @@ -64,6 +64,7 @@ class PipelineTestUtilsTest } "runWithOverride" should "override named transforms from the pipeline" in { + // #PipelineTestUtilsTest_example_run_with_overrides runWithOverrides( TransformOverride.of("multiply", (v: Int) => v * v), TransformOverride.ofIter("append", (v: Int) => Seq(v + "c", v + "d")) @@ -77,6 +78,7 @@ class PipelineTestUtilsTest result should containInAnyOrder(Seq("1c", "1d", "4c", "4d", "9c", "9d")) } + // #PipelineTestUtilsTest_example_run_with_overrides } it should "override named transforms if type signature are compatible" in { diff --git a/site/src/main/paradox/Scio-Unit-Tests.md b/site/src/main/paradox/Scio-Unit-Tests.md index 804d80e610..4eef3392f1 100644 --- a/site/src/main/paradox/Scio-Unit-Tests.md +++ b/site/src/main/paradox/Scio-Unit-Tests.md @@ -127,6 +127,10 @@ Can be overridden with static mock data: @@snip [JobTestTest.scala](/scio-test/src/test/scala/com/spotify/scio/testing/JobTestTest.scala) { #JobTestTest_example_source_mock } +It is alo possible to override a named `PTransform` during partial pipeline testing with `runWithOverrides`. + +@@snip [PipelineTestUtilsTest.scala](/scio-test/src/test/scala/com/spotify/scio/testing/PipelineTestUtilsTest.scala) { #PipelineTestUtilsTest_example_run_with_overrides } + Due to type erasure it is possible to provide the incorrect types for the transform and the error will not be caught until runtime. If you've specified the incorrect input type, scio will attempt to detect the error and throw an `IllegalArgumentException`,