Im new in Java and JUnit technology and I cant understand why I cant create instance for class from src/test in src/main classes?
For example:
My JUnit runner is in src/main in second module(I have dependecy for first module). JUnit runner for filtering tests required MethodSelector object but in constructor i must put Class javaClass, String methodName parameters. When I tried create instance for my test class in src/main from src/test I cant import this class...
I understand its not best practice when in src/main we create test instances but my runner must be console app so if I understand well it should be in src/main? Over the past two weeks I have not seen another way to filter tests without class instance and method names parameters.
I try to do it like this
def class = Class.forName("package.from.src.test")
but I always get java.lang.ClassNotFoundException error.
Can anyone help? Thanks
I am posting this very late but hoping it would help someone.
I was able to access a class from src/test into src/main using following gradle entries. I am not sure how to do it with non-gradle project.
sourceSets {
main {
java {
srcDirs 'src/main/java'
srcDirs 'src/test/java'
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.