emilssolmanis commented on a change in pull request #14272: URL: https://github.com/apache/beam/pull/14272#discussion_r614164238
########## 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<String> 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: @kennknowles agree with all of that. The code here _in my opinion_ does that, the step further here would be splitting out the testing modules so it doesn't all live in `-core`. So there'd be a `beam-junit4` and a `beam-junit5`, or alternatively junit4 remains in `core` for backwards compatibility and the Junit5 code is a new module. Happy to do either of those options if we think that's warranted, I'm unfamiliar with how Beam decides on what warrants a new module. -- 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]
