I’m trying to write a test to validate my use of @InputFiles
on a plugin written in Java.
I’ve finally arrived at a solution that uses my method for checking a List<File> (directories)
- Uses a
getXYZ
name, not some random name - Traverses all the directories and returns a file collection
- Use
@Internal
on the regular getter so I don’t get validation warnings.
So now I have a method that looks like this:
@Optional
@InputFiles
public FileCollection getDirectoriesAsInputFiles() {
if (directories == null) {
return null;
}
FileCollection files = project.files();
for (File directory : directories) {
files = files.plus(project.fileTree(directory));
}
return files;
}
@Internal
public List<File> getDirectories() {
return directories
}
However, it took me a couple of rounds of manually testing this to actually verify that the UP-TO-DATE
check works AND is actually calling this method.
Is there a way to write a test to verify that the UP-TO-DATE
check on a task is actually calling methods I think it is?