# Resources for writing tests against Gradle plugins in development?

**URL:** <https://discuss.gradle.org/t/resources-for-writing-tests-against-gradle-plugins-in-development/5296>\
**Category:** Old Forum Archive\
**Created:** [October 6, 2011, 4:58am UTC](https://discuss.gradle.org/t/resources-for-writing-tests-against-gradle-plugins-in-development/5296 "2011-10-06T04:58:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eriwen](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/eriwen/32/4786_2.png) [@eriwen](https://discuss.gradle.org/u/eriwen)\
**Post date:** [October 6, 2011, 4:58am UTC](https://discuss.gradle.org/t/resources-for-writing-tests-against-gradle-plugins-in-development/5296/1 "2011-10-06T04:58:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![luke\_daley](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/luke_daley/32/9890_2.png) [@luke\_daley](https://discuss.gradle.org/u/luke_daley)\
**Post date:** [October 6, 2011, 8:10am UTC](https://discuss.gradle.org/t/resources-for-writing-tests-against-gradle-plugins-in-development/5296/2 "2011-10-06T08:10:00Z")

</div>

Hi Eric,

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

[http://forums.gradle.org/gradle/topics/testing\_toolkit\_for\_custom\_build\_logic](http://forums.gradle.org/gradle/topics/testing_toolkit_for_custom_build_logic)

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.

---

<div class="post-metadata">

**Author:** ![kellyrob](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/kellyrob/32/1203_2.png) [@kellyrob](https://discuss.gradle.org/u/kellyrob)\
**Post date:** [October 22, 2011, 6:16pm UTC](https://discuss.gradle.org/t/resources-for-writing-tests-against-gradle-plugins-in-development/5296/3 "2011-10-22T18:16:00Z")

</div>

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: [https://github.com/kellyrob99/gradle-jslint-plugin/blob/master/src/test/groovy/org/kar/jslint/gradle/plugin/JSLintPluginTest.groovy](https://github.com/kellyrob99/gradle-jslint-plugin/blob/master/src/test/groovy/org/kar/jslint/gradle/plugin/JSLintPluginTest.groovy)

---

<div class="post-metadata">

**Author:** ![Warren](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/warren/32/7063_2.png) [@Warren](https://discuss.gradle.org/u/Warren)\
**Post date:** [May 2, 2012, 3:38am UTC](https://discuss.gradle.org/t/resources-for-writing-tests-against-gradle-plugins-in-development/5296/4 "2012-05-02T03:38:00Z")

</div>

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

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

```
