-
Notifications
You must be signed in to change notification settings - Fork 184
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
Migrate servicetalk-client-api
tests from jUnit4 to jUnit5
#1612
Migrate servicetalk-client-api
tests from jUnit4 to jUnit5
#1612
Conversation
servicetalk-client-api
tests from jUnit4 to jUnit5
@@ -1,5 +1,5 @@ | |||
/* | |||
* Copyright © 2018, 2020 Apple Inc. and the ServiceTalk project authors | |||
* Copyright © 2018, 2021 Apple Inc. and the ServiceTalk project authors |
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.
please change to 2018, 2020-2021
servicetalk-client-api/build.gradle
Outdated
testImplementation "junit:junit:$junitVersion" | ||
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit5Version" | ||
testImplementation "org.junit.jupiter:junit-jupiter-params:$junit5Version" | ||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit5Version" |
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.
mind moving this to the end of the file?
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.
Will do.
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.
looks good, some np comments and good to go
@tkountis Thanks for the review. I have made the changes. |
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.
Thank you for the PR @amitvc!
@@ -1,5 +1,5 @@ | |||
/* | |||
* Copyright © 2019 Apple Inc. and the ServiceTalk project authors | |||
* Copyright © 2021 Apple Inc. and the ServiceTalk project authors |
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.
* Copyright © 2021 Apple Inc. and the ServiceTalk project authors | |
* Copyright © 2019, 2021 Apple Inc. and the ServiceTalk project authors |
@@ -1,5 +1,5 @@ | |||
/* | |||
* Copyright © 2018 Apple Inc. and the ServiceTalk project authors | |||
* Copyright © 2021 Apple Inc. and the ServiceTalk project authors |
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.
* Copyright © 2021 Apple Inc. and the ServiceTalk project authors | |
* Copyright © 2018, 2021 Apple Inc. and the ServiceTalk project authors |
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.
Btw, you can skip updating copyright headers (we planning to automate this task) or use ./scripts/update-copyright.sh main
and that script will update everything correctly.
Exception e = assertThrows(ExecutionException.class, () -> { | ||
cf.newConnection("c1", null).toFuture().get(); | ||
cf.newConnection("c2", null).toFuture().get(); | ||
}); |
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.
The first newConnection
invocation is not expected to throw:
Exception e = assertThrows(ExecutionException.class, () -> { | |
cf.newConnection("c1", null).toFuture().get(); | |
cf.newConnection("c2", null).toFuture().get(); | |
}); | |
cf.newConnection("c1", null).toFuture().get(); | |
Exception e = assertThrows(ExecutionException.class, () -> cf.newConnection("c2", null).toFuture().get()); |
servicetalk-client-api/build.gradle
Outdated
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit5Version" | ||
testImplementation "org.mockito:mockito-core:$mockitoCoreVersion" | ||
testImplementation "org.hamcrest:hamcrest-library:$hamcrestVersion" |
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.
For future PRs, please place testRuntimeOnly
dependency after all testImplementation
dependencies. We try to sort by the scope first:
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit5Version" | |
testImplementation "org.mockito:mockito-core:$mockitoCoreVersion" | |
testImplementation "org.hamcrest:hamcrest-library:$hamcrestVersion" | |
testImplementation "org.mockito:mockito-core:$mockitoCoreVersion" | |
testImplementation "org.hamcrest:hamcrest-library:$hamcrestVersion" | |
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit5Version" |
@amitvc I will apply my suggestions. Please take a look at them and keep in mind for future PRs ❤️ |
…/DefaultAutoRetryStrategyProviderTest.java
…/DefaultClientGroupTest.java
…/LimitingConnectionFactoryFilterTest.java
@idelpivnitskiy Thank you very much. |
Motivation:
JUnit 5 leverages features from Java 8 or later, such as lambda functions, making tests more powerful and easier to maintain.
JUnit 5 has added some very useful new features for describing, organizing, and executing tests. For instance, tests get better display names and can be organized hierarchically.
JUnit 5 is organized into multiple libraries, so only the features you need are imported into your project. With build systems such as Maven and Gradle, including the right libraries is easy.
JUnit 5 can use more than one extension at a time, which JUnit 4 could not (only one runner could be used at a time). This means you can easily combine the Spring extension with other extensions (such as your own custom extension).
Modifications:
Unit tests have been migrated from JUnit 4 to JUnit 5
Result:
successfully ran ./gradlew :servicetalk-client-api:build
Module servicetalk-client-api now runs tests using JUnit 5