Mock test isolation in TestKit

I am attempting to test some complex plugins. One of those plugins has a task that makes a REST call as part of its processing. I am trying to figure out a way that i can replace the live REST client class with a test version that returns a mocked result object.

Is this possible in TestKit? It doesn’t look like it can be done. is this true?

If it is true, how is one supposed to isolate the task class and apply more traditional mock and unit proceedures on it?

TestKit is used for functional testing. What it sounds like you want to do is unit testing of some logic with a mock client. What we typically suggest is for Gradle tasks to be simply wrappers around some other class that does the work. You would then unit test that class with the mocking framework of your choice.

For functional testing you would then want to stand up some kind of server fixture for the build to communicate with. You could use something like Betamax or Wiremock for this.