-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FLINK-35490] Migrate tests to JUnit 5 and AssertJ #3742
base: master
Are you sure you want to change the base?
Conversation
3ee96e2
to
c2d2f94
Compare
c2d2f94
to
7603a2d
Compare
Most changes are just repetitive while some needs more attention:
|
b56570d
to
a4f142c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @yuxiqian 🚀 This is massive effort, thanks a lot!
I have added some suggestions, I will go over it again later on. Let's try to get this finalized soon
...ctor-kafka/src/test/java/org/apache/flink/cdc/connectors/kafka/sink/KafkaDataSinkITCase.java
Outdated
Show resolved
Hide resolved
assertTrue(expected != null && actual != null); | ||
assertEquals(expected.size(), actual.size()); | ||
assertArrayEquals(expected.toArray(new String[0]), actual.toArray(new String[0])); | ||
Assertions.assertThat(actual).containsExactlyInAnyOrderElementsOf(expected); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
...nector-db2-cdc/src/test/java/org/apache/flink/cdc/connectors/db2/source/Db2SourceITCase.java
Outdated
Show resolved
Hide resolved
...src/test/java/org/apache/flink/cdc/connectors/mongodb/source/MongoDBFullChangelogITCase.java
Outdated
Show resolved
Hide resolved
...ysql-cdc/src/test/java/org/apache/flink/cdc/connectors/mysql/source/MySqlSourceTestBase.java
Outdated
Show resolved
Hide resolved
flink-cdc-runtime/src/test/java/org/apache/flink/cdc/runtime/parser/JaninoCompilerTest.java
Outdated
Show resolved
Hide resolved
flink-cdc-runtime/src/test/java/org/apache/flink/cdc/runtime/parser/JaninoCompilerTest.java
Outdated
Show resolved
Hide resolved
...igration-testcases/src/test/java/org/apache/flink/cdc/migration/tests/MigrationTestBase.java
Outdated
Show resolved
Hide resolved
return Arrays.asList("1.19.1", "1.20.0"); | ||
if (Objects.isNull(flinkVersion)) { | ||
throw new IllegalArgumentException( | ||
"No Flink version specified to run this test. Please use -DspecifiedFlinkVersion to pass one."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previous test has default value. But it is good idea to throw here, since the release cycle is very frequent nowadays 👍
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mongodb-cdc/pom.xml
Outdated
Show resolved
Hide resolved
2797740
to
15b3ef2
Compare
Thanks for the quick review! Addressed comments and resolved conflicts. |
9e4352b
to
9f05c92
Compare
Signed-off-by: yuxiqian <[email protected]> # Conflicts: # flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-elasticsearch/pom.xml # flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-starrocks/pom.xml # flink-cdc-connect/flink-cdc-source-connectors/flink-connector-db2-cdc/src/test/java/org/apache/flink/cdc/connectors/db2/table/Db2ConnectorITCase.java # flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mongodb-cdc/src/test/java/org/apache/flink/cdc/connectors/mongodb/table/MongoDBConnectorITCase.java # flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mongodb-cdc/src/test/java/org/apache/flink/cdc/connectors/mongodb/table/MongoDBRegexFilterITCase.java # flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/test/java/org/apache/flink/cdc/connectors/mysql/table/MySqlConnectorITCase.java # flink-cdc-connect/flink-cdc-source-connectors/flink-connector-oracle-cdc/src/test/java/org/apache/flink/cdc/connectors/oracle/table/OracleConnectorITCase.java # flink-cdc-connect/flink-cdc-source-connectors/flink-connector-postgres-cdc/src/test/java/org/apache/flink/cdc/connectors/postgres/table/PostgreSQLConnectorITCase.java # flink-cdc-connect/flink-cdc-source-connectors/flink-connector-postgres-cdc/src/test/java/org/apache/flink/cdc/connectors/postgres/table/PostgreSQLSavepointITCase.java # flink-cdc-connect/flink-cdc-source-connectors/flink-connector-sqlserver-cdc/src/test/java/org/apache/flink/cdc/connectors/sqlserver/table/SqlServerConnectorITCase.java # flink-cdc-e2e-tests/flink-cdc-pipeline-e2e-tests/pom.xml # flink-cdc-e2e-tests/flink-cdc-pipeline-e2e-tests/src/test/java/org/apache/flink/cdc/pipeline/tests/utils/PipelineTestEnvironment.java # flink-cdc-e2e-tests/flink-cdc-source-e2e-tests/src/test/java/org/apache/flink/cdc/connectors/tests/utils/FlinkContainerTestEnvironment.java # Conflicts: # flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/test/java/org/apache/flink/cdc/connectors/mysql/table/MySqlConnectorITCase.java # Conflicts: # flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/test/java/org/apache/flink/cdc/connectors/mysql/source/assigners/state/PendingSplitsStateSerializerTest.java # flink-cdc-connect/flink-cdc-source-connectors/flink-connector-oceanbase-cdc/src/test/java/org/apache/flink/cdc/connectors/oceanbase/table/OceanBaseMySQLModeITCase.java # Conflicts: # flink-cdc-connect/flink-cdc-source-connectors/flink-cdc-base/src/test/java/org/apache/flink/cdc/connectors/base/source/assigner/state/PendingSplitsStateSerializerTest.java # Conflicts: # flink-cdc-connect/flink-cdc-source-connectors/flink-cdc-base/src/test/java/org/apache/flink/cdc/connectors/base/GenericConnectionPoolTest.java # flink-cdc-connect/flink-cdc-source-connectors/flink-cdc-base/src/test/java/org/apache/flink/cdc/connectors/base/MySqlChangeEventSourceExampleTest.java # flink-cdc-connect/flink-cdc-source-connectors/flink-cdc-base/src/test/java/org/apache/flink/cdc/connectors/base/source/assigner/state/PendingSplitsStateSerializerTest.java # flink-cdc-connect/flink-cdc-source-connectors/flink-cdc-base/src/test/java/org/apache/flink/cdc/connectors/base/source/meta/split/SourceSplitSerializerTest.java # flink-cdc-connect/flink-cdc-source-connectors/flink-cdc-base/src/test/java/org/apache/flink/cdc/connectors/base/testutils/UniqueDatabase.java # flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/test/java/org/apache/flink/cdc/connectors/mysql/source/assigners/state/PendingSplitsStateSerializerTest.java # flink-cdc-connect/flink-cdc-source-connectors/flink-connector-postgres-cdc/src/test/java/org/apache/flink/cdc/connectors/postgres/source/fetch/PostgresScanFetchTaskTest.java # flink-cdc-e2e-tests/flink-cdc-source-e2e-tests/src/test/java/org/apache/flink/cdc/connectors/tests/OracleE2eITCase.java # flink-cdc-runtime/src/test/java/org/apache/flink/cdc/runtime/parser/JaninoCompilerTest.java # flink-cdc-runtime/src/test/java/org/apache/flink/cdc/runtime/parser/TransformParserTest.java # Conflicts: # flink-cdc-e2e-tests/flink-cdc-pipeline-e2e-tests/src/test/java/org/apache/flink/cdc/pipeline/tests/MysqlE2eITCase.java
Signed-off-by: yuxiqian <[email protected]>
9f05c92
to
957c68d
Compare
This is a sequel PR based on @morazow's great work in #3395.
Currently, there are way too many unit tests and assertion frameworks, including JUnit-4 style
Assert
, JUnit-5 style Assertions, Hamcrest Matchers, AssertJ fluent assertions. JUnit 4, 5 (Jupier and Vintage) test frameworks are also used altogether, which is prone to mistakes.Among all these solutions, AssertJ is generally regarded as the most readable and expressive, and used as the assertion standard in many other projects like Apache Iceberg.
This PR migrates all existing test cases to JUnit 5 + AssertJ combination, with an enforced rule defined in spotless style check to forbid using any other testing / asserting frameworks.