I have Eclipse project in which i use Maven. I also use surefire plugin for tests. I wrote some test classes and tried to run mvn test
, however i get this exception:
java.lang.reflect.InaccessibleObjectException: Unable to make static void
dataaccesslayer.desktopapp.DesktopAppCRUDTest.setupTestingDatabase() accessible:
module registry.dataaccesslayer does not "opens dataaccesslayer.desktopapp" to unname
d module
I see that i am calling some static method (of class in src/main/java) in test class, which is causing this problem.
So i tought i could just write: opens dataaccesslayer.desktopapp
in module-info.java, however i can not write that, because module-info is in src/main/java and not src/test/java.
So is there a way to open test package in module-info.java? If not, what could i do to make test work when i am calling static methods of non-test classes? Is that a bad approach to call static methods of non-test classes in test classes?