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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup JUnit5 for jvmTest #37

Merged
merged 2 commits into from
May 8, 2023
Merged

Setup JUnit5 for jvmTest #37

merged 2 commits into from
May 8, 2023

Conversation

nomisRev
Copy link
Contributor

@nomisRev nomisRev commented May 8, 2023

Before:

org.gradle.api.internal.tasks.testing.TestSuiteExecutionException: Could not start Gradle Test Executor 60.
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.startProcessing(SuiteTestClassProcessor.java:44)
	at java.base@11.0.10/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base@11.0.10/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base@11.0.10/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base@11.0.10/java.lang.reflect.Method.invoke(Method.java:566)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
	at com.sun.proxy.$Proxy2.startProcessing(Unknown Source)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker$1.run(TestWorker.java:161)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113)
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65)
	at app//worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
	at app//worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
Caused by: org.junit.platform.commons.PreconditionViolationException: Cannot create Launcher without at least one TestEngine; consider adding an engine implementation JAR to the classpath
	at app//org.junit.platform.commons.util.Preconditions.condition(Preconditions.java:296)
	at app//org.junit.platform.launcher.core.DefaultLauncher.<init>(DefaultLauncher.java:55)
	at app//org.junit.platform.launcher.core.LauncherFactory.createDefaultLauncher(LauncherFactory.java:134)
	at app//org.junit.platform.launcher.core.LauncherFactory.openSession(LauncherFactory.java:98)
	at app//org.junit.platform.launcher.core.LauncherFactory.openSession(LauncherFactory.java:82)
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$BackwardsCompatibleLauncherSession.open(JUnitPlatformTestClassProcessor.java:256)
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.createTestExecutor(JUnitPlatformTestClassProcessor.java:77)
	at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.startProcessing(AbstractJUnitTestClassProcessor.java:50)
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.startProcessing(SuiteTestClassProcessor.java:42)
	... 18 more

After it works correctly and we can run ./gradlew build and ./gradlew integrationTest.
However, my IDEA is currently broken 馃槶 Everything in commonTest is red.

Screenshot 2023-05-08 at 11 54 54

@nomisRev
Copy link
Contributor Author

nomisRev commented May 8, 2023

@franciscodr @realdavidvega it seems the false-positives are not occurring here 馃 So perhaps something was merged incorrect in #33 or #35.

@nomisRev nomisRev requested a review from franciscodr May 8, 2023 09:56
@realdavidvega
Copy link
Contributor

Could be a bug, same happens to me, the inferred dependency of commonMain in commonTest is not there.
But by removing dependsOn(jvmTest) from jvmIntegrationTest, the red from commonMain disappears. But obviously then jvmIntegrationTest is in red 馃槄

Besides that, is jvmIntegrationTest some special syntax for the source set of integration tests in the JVM platform? because I see it's being generated by KMP, however I am not being able to find much information about it...

@franciscodr
Copy link
Contributor

franciscodr commented May 8, 2023

Could be a bug, same happens to me, the inferred dependency of commonMain in commonTest is not there. But by removing dependsOn(jvmTest) from jvmIntegrationTest, the red from commonMain disappears. But obviously then jvmIntegrationTest is in red 馃槄

Besides that, is jvmIntegrationTest some special syntax for the source set of integration tests in the JVM platform? because I see it's being generated by KMP, however I am not being able to find much information about it...

@realdavidvega The jvmIntegrationTest source set is generated by the KMP plugin after adding a new compilation target within the jvm block.

You can check out some documentation here

@nomisRev
Copy link
Contributor Author

nomisRev commented May 8, 2023

But by removing dependsOn(jvmTest) from jvmIntegrationTest, the red from commonMain disappears. But obviously then jvmIntegrationTest is in red 馃槄

What worked for me is adding dependsOn(commonMain) inside commonTest but then it said something like: _cannot find getenvfor JS and Native sourceSets. So it seems that creating the configuration forintegrationTest` breaks something in the tree.

@nomisRev
Copy link
Contributor Author

nomisRev commented May 8, 2023

@franciscodr @realdavidvega I posted a question on KotlinLang Slack in the #multiplatform channel. https://kotlinlang.slack.com/archives/C3PQML5NU/p1683554622114859

@nomisRev
Copy link
Contributor Author

nomisRev commented May 8, 2023

@realdavidvega @franciscodr I think I fixed it in 564cf2a

@nomisRev
Copy link
Contributor Author

nomisRev commented May 8, 2023

Alternatively, we associateWith main but then we have to redefine the junit5 runner for both jvmTest and jvmIntegrationTest so that both are completely separated. WDYT?

@nomisRev nomisRev merged commit bd65f41 into main May 8, 2023
1 check passed
@nomisRev nomisRev deleted the fix-jvmTest branch May 8, 2023 20:18
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.

None yet

4 participants