[ https://issues.apache.org/jira/browse/SUREFIRE-1811?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17147362#comment-17147362 ]
Pavel_K edited comment on SUREFIRE-1811 at 6/28/20, 3:21 PM: ------------------------------------------------------------- [~cowwoc] When you develop a real JPMS project (that contains N JPMS modules) you should consider many things. # You have API/SPI modules that export almost everything and you have impl modules that try to hide almost everything. The only communication with external world for impl modules are services, that are listed in module-info. # As a rule you test impl modules, and you have two types of tests - units tests and it tests. Both type of tests (and particularly it tests_ must also be in JPMS module and loaded to JPMS layer as they must test module in JPMS environment. # Test module must have its own JPMS settings. For this we use module-info.java or module-info.test (the last one I couldn't make work) # One of the most important task of modularization (-> and JPMS) is to help developer and to provide a mechanism for low coupling between module elements. So, taking all this into consideration we need to think about out testing approach. The simplest way is to export everything in main module - it is simple and it absolutely contradicts modularization principles. Another way is "export something to test-module" - it is better, but anyway is not very good as main module (the module under test) must know nothing about testing module. I am want to find the best way trying to implement different solutions. For example, the link I provided when I opened this issue references to project that uses shadowing of the main module-info and of course this solution contradicts to the most obvious {code:java} module main { exports everything; } {code} was (Author: pavel_k): [~cowwoc] When you develop a real JPMS project (that contains N JPMS modules) you should consider many things. # You have API/SPI modules that export almost everything and you have impl modules that try to hide almost everything. The only communication with external world for impl modules are services, that are listed in module-info. # As a rule you test impl modules, and you have two types of tests - units tests and it tests. Both type of tests (and particularly it tests_ must also be in JPMS module and loaded to JPMS layer as they must test module in JPMS environment. # Test module must have its own JPMS settings. For this we use module-info.java or module-info.test (the last one I couldn't make work) # One of the most important task of modularization (-> and JPMS) is to help developer and to provide a mechanism for low coupling between module elements. So, taking all this into consideration we need to think about out testing approach. The simplest way is to export everything in main module - it is simple and it absolutely contradicts modularization principles. Another way is "export something to test-module" - it is better, but anyway is not very good as main module (the module under test) must know nothing about testing module. I am want to find the best way trying to implement different solutions. For example, the link I provided when I opened this issue references to project that uses shadowing of the main module-info and of course this solution contradicts to the most obvious "module main { exports everything}". > Add resources to JPMS test module > --------------------------------- > > Key: SUREFIRE-1811 > URL: https://issues.apache.org/jira/browse/SUREFIRE-1811 > Project: Maven Surefire > Issue Type: New Feature > Components: Maven Failsafe Plugin > Affects Versions: 3.0.0-M5 > Reporter: Pavel_K > Priority: Major > > I am testing version 3.0.0-M5 with two module-info in one project - one main > and one for test. My test project is here > https://github.com/PashaTurok/hibernate-h2-test4 . The problem is with > resources. For example, I have src/main/resources/META-INF/persistence.xml > file that is not copied to test module. Because of this it is not possible to > find resource in test module and it is necessary to use something like this > https://github.com/PashaTurok/hibernate-h2-test4/blob/292e2e683ad72487cbf8d2e5a35dde0d9255001a/src/test/java/com/foo/hibernate/h2/test4/TestIT.java#L72 > . > In target/test-classes/META-INF/jpms.args I see: > {code:java} > --patch-module > my.project=/home/..../hibernate-h2-test4/src/main/java, > /home/.../hibernate-h2-test4/target/generated-sources/annotations > {code} > As I understand test module will NOT contain resources from the module under > test? I mean that test module will NOT contain > /home/..../hibernate-h2-test4/src/main/resources? > That's why I suggest to include src/main/resources in test module. -- This message was sent by Atlassian Jira (v8.3.4#803005)