Skip to content
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

Run JUnit 4 based tests using junit-vintage-engine #1452

Merged
merged 5 commits into from
Mar 23, 2021

Conversation

danfaer
Copy link
Contributor

@danfaer danfaer commented Mar 23, 2021

Motivation:
Let developers to create new JUnit 5 tests in modules not yet converted to JUnit5

Modifications:
added dependency on org.junit.vintage:junit-vintage-engine

Result:
JUnit 4 and JUnit 5 tests can be mixed in one module
To add new JUnit 5 tests to non converted test module, the following dependencies news to be present:

testImplementation "org.junit.jupiter:junit-jupiter-api:$junit5Version"
testImplementation "org.junit.jupiter:junit-jupiter-params:$junit5Version" (optional if using parameterized tests)
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit5Version"

Copy link
Member

@idelpivnitskiy idelpivnitskiy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment then LGTM, thank you @danfaer!

@@ -161,6 +161,14 @@ final class ServiceTalkLibraryPlugin extends ServiceTalkCorePlugin {
private static void configureTests(Project project) {
project.configure(project) {
test {
useJUnitPlatform()
// expected format for timeout: <number>[ns|μs|ms|s|m|h|d])
def junit5DefaultTimeout = System.getProperty("CI") ? "30s" : "10s"
Copy link
Member

@idelpivnitskiy idelpivnitskiy Mar 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure System.getProperty("CI") will give us what we need, should we use Boolean.getBoolean("CI")?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the CI is not a system property, it's env variable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

environment: &environment
- CI

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using System.getenv("CI") instead

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps def junit5DefaultTimeout = Boolean.valueOf(System.getenv("CI") ?: "false") ? "30s" : "10s"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that looks better

@idelpivnitskiy idelpivnitskiy merged commit 0a154c2 into apple:main Mar 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants