Does anyone know if there is a way to inject a test-double of a
BuildService
like
ExecOperations
using the test-kit?
v
Vampire
11/06/2024, 2:52 PM
Don't think so
t
Thomas Broyer
11/06/2024, 3:35 PM
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
Remco Mokveld
11/15/2024, 7:31 AM
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
Vampire
11/15/2024, 8:31 AM
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.
Vampire
11/15/2024, 8:33 AM
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. 🤷♂️