You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/05/19 09:58:59 UTC

[GitHub] [flink] zentol commented on a diff in pull request #19753: [FLINK-27672][tests][table] Migrate flink-table-common to JUnit5

zentol commented on code in PR #19753:
URL: https://github.com/apache/flink/pull/19753#discussion_r876855264


##########
flink-table/flink-table-common/src/test/java/org/apache/flink/table/types/LogicalTypeDuplicatorTest.java:
##########
@@ -34,53 +34,46 @@
 import org.apache.flink.table.types.logical.VarCharType;
 import org.apache.flink.table.types.logical.utils.LogicalTypeDuplicator;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
 
 import java.util.Arrays;
 import java.util.Collections;
-import java.util.List;
+import java.util.stream.Stream;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
 /** Tests for {@link LogicalTypeDuplicator}. */
-@RunWith(Parameterized.class)
-public class LogicalTypeDuplicatorTest {
+class LogicalTypeDuplicatorTest {
 
     private static final LogicalTypeDuplicator DUPLICATOR = new LogicalTypeDuplicator();
 
     private static final LogicalTypeDuplicator INT_REPLACER = new IntReplacer();
 
-    @Parameters(name = "{index}: {0}")
-    public static List<Object[]> testData() {
-        return Arrays.asList(
-                new Object[][] {
-                    {new CharType(2), new CharType(2)},
-                    {createMultisetType(new IntType()), createMultisetType(new BigIntType())},
-                    {createArrayType(new IntType()), createArrayType(new BigIntType())},
-                    {createMapType(new IntType()), createMapType(new BigIntType())},
-                    {createRowType(new IntType()), createRowType(new BigIntType())},
-                    {createDistinctType(new IntType()), createDistinctType(new BigIntType())},
-                    {createUserType(new IntType()), createUserType(new BigIntType())},
-                    {createHumanType(), createHumanType()}
-                });
+    static Stream<Arguments> testData() {

Review Comment:
   private



##########
flink-table/flink-table-common/src/test/java/org/apache/flink/table/types/inference/InputTypeStrategiesTestBase.java:
##########
@@ -45,39 +43,39 @@
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 /** Base class for testing {@link InputTypeStrategy}. */
-@RunWith(Parameterized.class)
 public abstract class InputTypeStrategiesTestBase {
 
-    @Parameterized.Parameter public TestSpec testSpec;
-
-    @Test
-    public void testStrategy() {
+    @ParameterizedTest

Review Comment:
   ```suggestion
   ```
   Since the method is called from the sub-classes.
   
   Although I'm curious; what would happen if this method had a `@MethodSource`, but the method only exists in sub-classes?



##########
flink-table/flink-table-common/src/test/java/org/apache/flink/table/types/inference/InputTypeStrategiesTestBase.java:
##########
@@ -45,39 +43,39 @@
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 /** Base class for testing {@link InputTypeStrategy}. */
-@RunWith(Parameterized.class)
 public abstract class InputTypeStrategiesTestBase {
 
-    @Parameterized.Parameter public TestSpec testSpec;
-
-    @Test
-    public void testStrategy() {
+    @ParameterizedTest

Review Comment:
   What we could also try is using Lifecycle.PER_CLASS and an abstract `testData()` method that sub-classes implement.



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org