Mocking project.ant, best approach

In my task action I would like to implement a mock for the project antbuilder. I’m not too concerned what happens during that ant task call, but I would like to validate through unit testing that antBuilderInput is being populated correctly.

@TaskAction
    void runWlDeployCommand() {
          antBuilderInput = [:]
        antBuilderInput += getConnectionArgs()
        antBuilderInput += getUserCredentialArgs()
        antBuilderInput += getCommonArgs()
          ant.taskdef( name: 'wldeploy',
                    classname: 'weblogic.ant.taskdefs.management.WLDeploy',
                    classpath: project.configurations.weblogic.asPath )
        ant.wldeploy( antBuilderInput )
      }

Any help would be gratefully received.

Task actions are difficult to unit test. Instead I’d look for other solutions, such as extracting population of ‘antBuilderInput’ and testing it separately.

Thanks Peter, I had thought that may be the case. It should be easy enough for me to test in other ways - it may cause problems with future implementations but I will cross those bridges when they arrive.