TestKit with Spock - Mismatch between directory set in GradleRunner to what the plugin uses

test-tag

(Gabriel Kohen) #1

Hi Folks,

We’re using the Gradle 4.8. the development env is MacOS.
We set up the Build result as follows:
BuildResult buildResult = GradleRunner.create()
.withProjectDir(testProjectDir.root)
.withPluginClasspath()
.withArguments(’–debug’, ‘–stacktrace’, ‘–dry-run’, task)
.forwardOutput()
.withDebug(true)
.build()
Where testProjectDir is set in the class as:
@Rule
private final TemporaryFolder testProjectDir = new TemporaryFolder()
When inspecting the value in the test stackframe I see something in the lines of:
/var/folders/ll/5_c9n_mj06l4gkmjwfwmxk080000gp/T/junit6618640855114483875

However on the same run, when putting a breakpoint inside of the plugin itself which is under test, I see the project location as:
/private/var/folders/ll/5_c9n_mj06l4gkmjwfwmxk080000gp/T/junit6618640855114483875

I thought the directory used should be what we specify in the runner. There reason it’s important for us is because as part of the test setup we’re creating a directory under testProjectDir which the plugin needs to interact with.

Any ideas of what I’m missing.

Thanks
-Gabriel