emilssolmanis commented on a change in pull request #14272:
URL: https://github.com/apache/beam/pull/14272#discussion_r604040380



##########
File path: 
sdks/java/core/src/main/java/org/apache/beam/sdk/testing/TestPipelineJunit5.java
##########
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.testing;
+
+import static 
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions.checkState;
+
+import java.lang.reflect.Method;
+import org.apache.beam.sdk.options.ApplicationNameOptions;
+import org.apache.beam.sdk.options.PipelineOptions;
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+
+/**
+ * An extension of {@link TestPipeline} that implements the JUnit5 Extensions 
model.
+ *
+ * <p>Usage is the same as {@link TestPipeline}, but the instantiation has to 
be done via JUnit5's
+ * {@link org.junit.jupiter.api.extension.RegisterExtension} annotation 
mechanism, like
+ *
+ * <p>The {@link NeedsRunner} category tagging is replaced with JUnit5's {@link
+ * org.junit.jupiter.api.Tag} mechanism, the equivalent tag is {@literal 
needsRunner}.
+ *
+ * <pre><code>
+ * {@literal @RegisterExtension}
+ *  public final transient TestPipelineJunit5 p = TestPipelineJunit5.create();
+ *
+ * {@literal @Test}
+ * {@literal @Tag}("needsRunner")
+ *  public void myPipelineTest() throws Exception {
+ *    final PCollection&lt;String&gt; pCollection = pipeline.apply(...)
+ *    PAssert.that(pCollection).containsInAnyOrder(...);
+ *    pipeline.run();
+ *  }
+ * </code></pre>
+ *
+ * <p>See also the <a 
href="https://beam.apache.org/contribute/testing/";>Testing</a> documentation
+ * section.
+ */
+@SuppressWarnings({
+  "nullness" // TODO(https://issues.apache.org/jira/browse/BEAM-10402)
+})
+public class TestPipelineJunit5 extends TestPipeline

Review comment:
       @TheNeuralBit not without breaking clients, unfortunately. That was my 
first idea, but adding the JUnit5 imports to `TestPipeline` then makes JUnit5 a 
compile dependency for anything that uses `TestPipeline`.
   
   I don't mind adding the dependency to the tens of Beam modules, but the more 
important part is of course that it would force anyone doing testing with 
JUnit4 to add a JUnit5 API dependency as well just for their code to compile.
   
   Currently the testing deps are all `provided`, the alternative is marking 
some of them as `compile`, but I'm not sure that's a good approach either.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to