Resources for writing tests against Gradle plugins in development?

Where could I find some resources for writing unit/integration tests for Gradle plugins I’m developing? Looking at all of the 3rd party plugins, it seems almost no one has any tests. It also seems like the handy test fixtures are kept internal to gradle. Please advise.

Hi Eric,

There’s currently no way to practically integration test custom build logic. Fixing this is on our roadmap.

The stuff that is in the Gradle build itself won’t work outside of the Gradle build, and is not really suitable for that use anyway. What we do eventually provide will end up with a similar kind of interface but needs to be implemented very differently.

If you’re just looking to unit test, the ProjectBuilder api has some facilities that can help. Here’s an example of unit testing a plugin:

Did you get this to work with debug logging? I could not properly instantiate the logger. So change the project.logging.debug in the real class to a debug(Project project, String output) and called that to log and check if logger was not null, etc. The println is to enable debug on the test results page. Its hacky but it works until I can work out

def debug (Project project, String output) {
    if (project != null && project.logger != null) {
    //Assume test env ?
    if (project==null || project.logger==null) {
      println output