This message was deleted.
# community-support
s
This message was deleted.
v
You configured that all dependencies you declare on
testImplementation
are also available to
integrationTestImplementation
and that
integrationTestImplementation
dependends on
project
. What you miss is a dependency from
integrationTestImplementation
to the test classes. But actually I'd suggest you instead add the
java-test-fixtures
plugin to the mix and put the shared classes into the test fixtures source set, then depend on that from test and integrationTest.
m
actually the available dependencies are on propose. Thanks! I tried the
java-test-fixtures
and it solved almost all my issues, but I’ve encountered strange NPE I have no idea how to fix: I’m accessing file from resource this way:
Copy code
val file = File(javaClass.getResource("/folder/file.txt").file)
but it crashes because of:
Copy code
java.io.FileNotFoundException: file:/PATH/build/libs/APP.jar!/folder/file.txt (No such file or directory)
but when I unzip the jar, the file is there on correct path. There was no issue with it when it was directly in the test/resources folder
v
That's not an NPE. And well, you cannot use a resource from the class path that way. It just coincidentally works if the class path entry is a directory, not a jar.
m
I’ll add more details: I’m trying to use it in Spring Boot app tests. In the production code (main) I access some certificates from the main/resources folder (this is just for local development). When I add
testFixtures
, even the basic
contextLoads()
test fails, because it can’t find the certificates - it seems the main/resources is no longer accessible. I tried something like this:
Copy code
sourceSets {
    testFixtures {
        resources {
            setSrcDirs(listOf("src/main/resources"))
        }
    }
}
or
Copy code
java.sourceSets["testFixtures"].resources {
    srcDir("src/main/resources")
}
but that didn’t help. I tried google and stackoveflow, but I wasn’t successful either. Is there a way how to propagate man/resources to the
testFixtures
?
v
Just properly use the resource properly instead. If your really need it as file, cigs l copy it to a temp file. Or give the path to the test add property. But do not get the file as resource and then just use it as file, that is inherently broken