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

Correct configuration of Test Sources Root in Gradle project in IDEA 2022.1.3 #520

Closed
alisevych opened this issue Jul 13, 2022 · 2 comments
Assignees
Labels
comp-ui Improvements of plugin UI appearence and functionality ctg-bug Issue is a bug status-wont-fix This will not be worked on

Comments

@alisevych
Copy link
Member

Description

Generated tests - to a new test sources root - cannot be run in IDEA 2022.1.3 for Gradle project:
java.lang.ClassNotFoundException
Need to:

  1. configure new test source root in Gradle // most probably, build.gradle file
  2. warn user that this configuration will be made

To Reproduce

Preconditions:

  1. IntelliJ IDEA is running.
  2. New version of UTBotJava plugin is installed.
  3. Gradle project with JDK 8-11 is opened.
  4. There is a class in src/main/java
  5. There is a default test root present, aka src/test/java

Steps to reproduce the behavior:

  1. Open UTBot dialog for the class or a method in it.
  2. Click ... for Test source root
  3. Create a new folder in src/test - f.e. utbot-tests
  4. Click OK => utbot-tests folder is marked as Test source root and test class is generated into it.
  5. Run the generated test

Expected behavior

Test should be successfully executed.

Actual behavior

Red text "No tests were found" is displayed in Run tab.

Visual proofs (screenshots, logs, images)

Internal Error occurred.
org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-jupiter' failed to discover tests
	at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:111)
	at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:85)
	at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:92)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
	at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: org.junit.platform.commons.JUnitException: ClassSelector [className = 'abc.ATest'] resolution failed
	at org.junit.platform.launcher.listeners.discovery.AbortOnFailureLauncherDiscoveryListener.selectorProcessed(AbortOnFailureLauncherDiscoveryListener.java:39)
	at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolveCompletely(EngineDiscoveryRequestResolution.java:102)
	at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.run(EngineDiscoveryRequestResolution.java:82)
	at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolver.resolve(EngineDiscoveryRequestResolver.java:113)
	at org.junit.jupiter.engine.discovery.DiscoverySelectorResolver.resolveSelectors(DiscoverySelectorResolver.java:45)
	at org.junit.jupiter.engine.JupiterTestEngine.discover(JupiterTestEngine.java:69)
	at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:103)
	... 9 more
Caused by: org.junit.platform.commons.PreconditionViolationException: Could not load class with name: abc.ATest
	at org.junit.platform.engine.discovery.ClassSelector.lambda$getJavaClass$0(ClassSelector.java:75)
	at org.junit.platform.commons.function.Try$Failure.getOrThrow(Try.java:335)
	at org.junit.platform.engine.discovery.ClassSelector.getJavaClass(ClassSelector.java:74)
	at org.junit.jupiter.engine.discovery.ClassSelectorResolver.resolve(ClassSelectorResolver.java:66)
	at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.lambda$resolve$2(EngineDiscoveryRequestResolution.java:134)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1632)
	at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
	at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
	at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:185)
	at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:125)
	at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolveCompletely(EngineDiscoveryRequestResolution.java:91)
	... 14 more
Caused by: java.lang.ClassNotFoundException: abc.ATest
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	at org.junit.platform.commons.util.ReflectionUtils.lambda$tryToLoadClass$9(ReflectionUtils.java:792)
	at org.junit.platform.commons.function.Try.lambda$call$0(Try.java:57)
	at org.junit.platform.commons.function.Try.of(Try.java:93)
	at org.junit.platform.commons.function.Try.call(Try.java:57)
	at org.junit.platform.commons.util.ReflectionUtils.tryToLoadClass(ReflectionUtils.java:755)
	at org.junit.platform.commons.util.ReflectionUtils.tryToLoadClass(ReflectionUtils.java:711)
	... 29 more

Environment

Windows 10 Pro
IntelliJ IDEA 2022.1.3 - not reproducing in old IDEA 2020.3
JDK 8 / 11 , Gradle 6.8 / 7.3.3

@alisevych alisevych added ctg-bug Issue is a bug comp-ui Improvements of plugin UI appearence and functionality labels Jul 13, 2022
@korifey korifey moved this to Todo in UTBot Java Jul 13, 2022
@alisevych alisevych changed the title Test Sources Root is not correctly configured in Gradle project in IDEA 2022.1.3 Correct configuration of Test Sources Root in Gradle project in IDEA 2022.1.3 Jul 13, 2022
@Vassiliy-Kudryashov
Copy link
Member

The issue seems to be fixed within #549 now custom (not defined in Gradle) test source roots are prohibited. We add them with IntelliJ API but they won't works. Custom test source roots have to be added manually via build.gradle or config files like this.

@alisevych
Copy link
Member Author

After #657 was implemented -
it was decided to leave Gradle test source root configuration for the user. Just suggest a link to documentation on that.

@alisevych alisevych closed this as not planned Won't fix, can't repro, duplicate, stale Aug 10, 2022
Repository owner moved this from Todo to Done in UTBot Java Aug 10, 2022
@alisevych alisevych added the status-wont-fix This will not be worked on label Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-ui Improvements of plugin UI appearence and functionality ctg-bug Issue is a bug status-wont-fix This will not be worked on
Projects
Archived in project
Development

No branches or pull requests

2 participants