You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While using utbot-cli to generate unit tests for open source projects, we hit the issue like: java.lang.NullPointerException: relativePathForClass.parent must not be null while running. In https://github.com/UnitTestBot/UTBotJava/blob/main/utbot-cli/src/main/kotlin/org/utbot/cli/ClassLoaderUtils.kt#L18, it tries to find parent directory of relativePathForClass and failed. This happens when some compiled maven projects have .class files right under /target/classes directory without any parent directories.
use java 8 to run mvn dependency:build-classpath --define mdep.outputFile=/tmp/classpath.txt to store dependency classpath into a file.
use java 8 to run mvn compile and compile the project
compile UTBotJava and get utbot-cli.jar
Run bunchGenerate command through code like java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.ref=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.locks=ALL-UNNAMED --add-opens=java.base/jdk.internal.icu.util=ALL-UNNAMED --add-opens=java.base/sun.security.util=ALL-UNNAMED --add-opens=java.logging/java.util.logging=ALL-UNNAMED -jar /<Relative Path to utbot-cli>/utbot-cli.jar bunchGenerate --test-framework junit5 --classpath /<Relative path to IO project >/src/target/classes --classpathFile /tmp/classpath.txt --output <Any output path>
Expected behavior
Tests are supposed to be generated.
Actual behavior
hit NullPointerException
Visual proofs (screenshots, logs, images)
java.lang.NullPointerException: relativePathForClass.parent must not be null
--
11621 | at org.utbot.cli.ClassLoaderUtilsKt.loadClassesFromPath(ClassLoaderUtils.kt:18)
11622 | at org.utbot.cli.BunchTestGeneratorCommand.run(BunchTestGeneratorCommand.kt:68)
11623 | at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:204)
11624 | at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:213)
11625 | at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:17)
11626 | at com.github.ajalt.clikt.core.CliktCommand.parse(CliktCommand.kt:396)
11627 | at com.github.ajalt.clikt.core.CliktCommand.parse$default(CliktCommand.kt:393)
11628 | at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:411)
11629 | at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:436)
11630 | at org.utbot.cli.ApplicationKt.main(Application.kt:31)
Description
While using utbot-cli to generate unit tests for open source projects, we hit the issue like:
java.lang.NullPointerException: relativePathForClass.parent must not be null while running
. In https://github.com/UnitTestBot/UTBotJava/blob/main/utbot-cli/src/main/kotlin/org/utbot/cli/ClassLoaderUtils.kt#L18, it tries to find parent directory of relativePathForClass and failed. This happens when some compiled maven projects have .class files right under/target/classes
directory without any parent directories.To Reproduce
Steps to reproduce the behavior:
mvn dependency:build-classpath --define mdep.outputFile=/tmp/classpath.txt
to store dependency classpath into a file.mvn compile
and compile the projectjava --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.ref=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.locks=ALL-UNNAMED --add-opens=java.base/jdk.internal.icu.util=ALL-UNNAMED --add-opens=java.base/sun.security.util=ALL-UNNAMED --add-opens=java.logging/java.util.logging=ALL-UNNAMED -jar /<Relative Path to utbot-cli>/utbot-cli.jar bunchGenerate --test-framework junit5 --classpath /<Relative path to IO project >/src/target/classes --classpathFile /tmp/classpath.txt --output <Any output path>
Expected behavior
Tests are supposed to be generated.
Actual behavior
hit NullPointerException
Visual proofs (screenshots, logs, images)
Environment
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: