Does anyone know if there is a way to inject a tes...
# plugin-development
r
Does anyone know if there is a way to inject a test-double of a
BuildService
like
ExecOperations
using the test-kit?
v
Don't think so
t
TestKit is about end-to-end/functional testing, so you can't control much about Gradle. And AFAIK even ProjectBuilder doesn't allow you to control how/what Gradle injects into your objects. This means that either you mock everything, or you "integration test" everything.
r
Alright, I was hoping to be able run test a task that executes a git commit without having to make sure that git is actually installed on the device and that the project dir is an actual git repo, but I guess I'll then need to initialize a git repository before running the functional test
v
Maybe you should anyway make the plugin compatible with those situations? Otherwise a build will fail if it for example is run from an exported source archive.
Anyway, what you could do is, you create a shared build service that is doing the actual git work and can be controlled by some system property to not do actual git commands. 🤷‍♂️