IntelliJ test classpath: Different when running class vs package

markdsievers

I have multi module project that has a test module specifically for running integration tests. I've noticed the test classpath changes significantly when running a single class vs running all the same package.

From inspection I can see another project module (and it's dependencies) are being added to the classpath that is not a dependency of the test module (direct or transitive) - it is fact a database migration library that is not depended on by anything else.

Can anyone rationalise why a test classpath would change when running a single class vs all 3 classes in that same package?

Background: IntelliJ 14.1.3 Tests pass when running via Maven

markdsievers

The difference could be seen in the Run... Run Configurations sections.

When using the Run... option for a package, the Test kind defaults to All in Package however the Package does not default to the package used when invoking Run.... The default Use classpath of module was greyed out (and will remain that way until you select a Package), so it looks like the classpath of all modules was used.

Use classpath of module was the option I needed to correct the classpath when running all tests in a package.

enter image description here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

When running tests from "sbt test" the classpath is different than when running from IDEA

Running Tomcat server Intellij Skip the test class

IntelliJ Error when running unit test: Could not find or load main class ${surefireArgLine}

Exclude class or package inside classpath when starting an application

Thread count is different when debugging or running on IntelliJ

TeamCity is running the same test twice, after the test was moved to a different package

Use IntelliJ Idea module classpath when running Maven goal from IntelliJ Idea

No test coverage when tests are in a different package

Class Not Found Exception when running JUnit test

nullPointerException on sharedpreferences helper class When running a test

'Class not found' when running JUnit test

Is there a shortcut in IntelliJ to import a class from a different package (than already imported)?

IntelliJ can't find classpath test resource

JUnit test in nested Kotlin class not found when running gradle test

Intellij - when the folder structure is different than the package name

IntelliJ error when package name different than the folder name

weld-se unable to find bean in different jar on classpath when running from command line

IntelliJ MyClass.class (No such file or directory) when running application

Running Java class in Gradle task with custom classpath

.Net/VS Test runner fails when running in Azure DevOps

Create Test Class in IntelliJ

Spring - Different test results when running from JUnit and Maven

Different output when running command in bash script vs terminal

Scala Intellij running test suite

Classpath resource not found when running as jar

'Batik not in classpath' error when running servlet

LWJGL / STB: Inconsistency when running in IntelliJ vs. running over Console

TypeError: Cannot call a class as a function when running Jest test

Unable to get a resource when running an main class or test in sbt