-
Notifications
You must be signed in to change notification settings - Fork 54
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
chore: Migrate Junit 4 to Junit 5 for showcase #2757
Conversation
…add unit-vintage-engine.
...e/gapic-showcase/src/test/java/com/google/showcase/v1beta1/ComplianceClientHttpJsonTest.java
Outdated
Show resolved
Hide resolved
showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITGdch.java
Outdated
Show resolved
Hide resolved
showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITAutoPopulatedFields.java
Outdated
Show resolved
Hide resolved
showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITApiVersionHeaders.java
Outdated
Show resolved
Hide resolved
showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITAutoPopulatedFields.java
Show resolved
Hide resolved
showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITHttpAnnotation.java
Outdated
Show resolved
Hide resolved
showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelMetrics.java
Show resolved
Hide resolved
showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/update.sh
Outdated
Show resolved
Hide resolved
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.
LGTM. Added a few nits. If you could test them locally and see if they work.
Since Min is OOO, I will take a look a final few things for this issue and merge if everything else looks fine. |
Looks like the ITs aren't actually running. |
I see it is running the tests now:
|
<groupId>org.junit</groupId> | ||
<artifactId>junit-bom</artifactId> | ||
<version>5.10.2</version> | ||
<type>pom</type> | ||
<scope>import</scope> |
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.
As this doesn't inherit from shared-deps or pom-parent, we declare the version here.
showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITServerSideStreaming.java
Outdated
Show resolved
Hide resolved
Quality Gate passed for 'gapic-generator-java-root'Issues Measures |
Quality Gate passed for 'java_showcase_integration_tests'Issues Measures |
@@ -116,6 +117,15 @@ | |||
<plugin> | |||
<groupId>org.apache.maven.plugins</groupId> | |||
<artifactId>maven-failsafe-plugin</artifactId> | |||
<!-- Shared-Configs defines JUnit Provider 4.7 as default: https://github.com/googleapis/java-shared-config/blob/465bb399aef9aa8383f11c23f10a97df49c1d057/java-shared-config/pom.xml#L86-L92 --> | |||
<!-- Override it here for showcase only as other libraries may still be reliant on JUnit4 --> | |||
<dependencies> |
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.
Do we know why the integration tests would not run without this change?
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.
I believe it's due the failsafe using junit-provider 4.7 (which works for junit 4.7+) as the selected provider instead of junit-platform: https://maven.apache.org/surefire/maven-failsafe-plugin/examples/junit-platform.html#provider-selection
fixes #2728, attempt to remove Junit 4 support after migration. Other than POM dependency migrate, changes include: - package name changes - Junit 5 syntax upgrades, e.g. `@Before` --> `@BeforeEach`, Replace assertion methods - remove public modifier on tests and test classes. - Refactor JUnit 4 TemporaryFolder `@Rule` in [ITGdch.java](https://github.com/googleapis/sdk-platform-java/pull/2757/files#diff-6ae7755a0b038e1a2febae2d27e36c762f6751b8c7db577421667069399884b4) to JUnit 5 `@TempDir` - Replace `@Test(timeout = 15000L)` in [ITClientShutdown.java](https://github.com/googleapis/sdk-platform-java/pull/2757/files#diff-70d1df57471178a7a63302f82e4a4855ffbbd642ea67d92d501bd1f7008957ca) with `@Timeout(15)` - Update `@RunWith(Parameterized.class)` test in [ITHttpAnnotation.java](https://github.com/googleapis/sdk-platform-java/pull/2757/files#diff-03d420650ecc9fe78ad4887761043c4fdceaa978f464ce30cfc4ed5f8be9b64d) to `@ParameterizedTest` with `@MethodSource("data")` ~~Note: #2737 creates a new test class with JUnit4 syntax. Depending on merging order, I will either update in this pr, or #2737.~~ Updated. Due to truth library depending on junit 4 ([see issue](google/truth#333)), junit 4 cannot be completely removed, or will encounter `java.lang.ClassNotFoundException: org.junit.runner.notification.RunListener` running tests with maven surefire. To keep things cleaner, excluding the implicitly junit brought in from truth and `junit-vintage-engine`. We could also do the reverse, and make a comment if that's prefered. --------- Co-authored-by: Burke Davison <[email protected]> Co-authored-by: Lawrence Qiu <[email protected]>
fixes #2728, attempt to remove Junit 4 support after migration.
Other than POM dependency migrate, changes include:
@Before
-->@BeforeEach
, Replace assertion methods@Rule
in ITGdch.java to JUnit 5@TempDir
@Test(timeout = 15000L)
in ITClientShutdown.java with@Timeout(15)
@RunWith(Parameterized.class)
test in ITHttpAnnotation.java to@ParameterizedTest
with@MethodSource("data")
Note: #2737 creates a new test class with JUnit4 syntax. Depending on merging order, I will either update in this pr, or #2737.Updated.Due to truth library depending on junit 4 (see issue), junit 4 cannot be completely removed, or will encounter
java.lang.ClassNotFoundException: org.junit.runner.notification.RunListener
running tests with maven surefire. To keep things cleaner, excluding the implicitly junit brought in from truth andjunit-vintage-engine
. We could also do the reverse, and make a comment if that's prefered.