Unit test for a function in custom gradle plugin


I created a gradle plugin using groovy.The plugin has a class that in turn has a function to modify and copy a json file from one location to another.

def copyFunction {
project.copy {
from 'source location’
into 'target location’
filter ( ReplaceTokens, tokens: [‘key’: ‘value’])

How can i write a unit test case for this function?
Please help as i am pretty new to gradle .

Thanks in advance

There is a Gradle Guide on Testing Gradle plugins.

However, you haven’t written any custom logic that’s unit testable or really even integration testable. You’re calling the Gradle API to copy actual files in the context of a build, so you should focus on the functional testing section of the guide and documentation on using Gradle TestKit.

1 Like

Thanks james . I got the point.