Run Jigsaw Unit Test on module-path

Answered

How can I run a unit test of a module with module-info.java on the module path? Maven does this with a module patch I guess.

@Test
public void testModuleName(){
String moduleName = HelloModule.getModuleName();
Assertions.assertThat(moduleName).isEqualTo("de.eiswind.hello_module");
}

Works with maven, gives null on the classpath in intellij.

0
5 comments
Avatar
Yaroslav Bedrov

Hello Thomas,

Please follow the related issue on YouTrack: https://youtrack.jetbrains.com/issue/IDEA-171419

 

0
Avatar
Permanently deleted user

I'm having the same problem (using Ultimate 2018.3.3). I checked the YouTrack link posted by Yaroslav, but didn't find a solution or workaround (the issue is still open it seems).

0

Unfortunately there is no fix yet, please follow the ticket for updates.

0
Avatar
Permanently deleted user

I have the same problem working on a multi module project using maven.

Unit testing of the modules classes works with maven when inserting the module-info.java file in the src/test/java directory. Both modules (main/ test) have the same name whereas the module-info.java in the test source tree contains some additional requires statements compared to the module-info.java file in der main source tree.

Running the build with Java 15 either on the console or within the IDE works fine and the tests are executed.

When trying to edit the tests in the IntelliJ editor, the classes from the main source tree are marked red because the module containing module could not be read.

Am I missing a link or is this still an issue not solved three years after the release of the JPMS?

IntelliJ IDEA 2020.2.2 (Ultimate Edition)
Build #IU-202.7319.50, built on September 15, 2020
Licensed to **************

Runtime version: 11.0.8+10-b944.31 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 10.15.6
GC: ParNew, ConcurrentMarkSweep
Memory: 1981M
Cores: 8
Registry: analyze.exceptions.on.the.fly=true, debugger.watches.in.variables=false
Non-Bundled Plugins: IdeaVIM, Lombook Plugin, org.jetbrains.plugins.hocon, com.jetbrains.lang.ejs, com.intellij.plugins.html.instantEditing, org.intellij.scala, com.jetbrains.php

0

@...

Please create a new issue on our tracker for this and provide a demo project to reproduce the problem on (either attach it to the issue or upload to uploads.jetbrains.com and provide the id).

0

Please sign in to leave a comment.