Testing Gradle Tasks

This seems to be tricky to search for given the JUnit and TestNG support. What I’m after though are conventions/techniques for writing tasks to test other tasks.

I have some build tasks that take some properties passed in and some are configured. For the test task, I need to configure different values for those properties.

a) anyone else actually trying to do this? b) anyone have suggestions for how to effectively layer this in your gradle files? c) anyone know of any good resources on this topic?

Thanks.

#rob

The recommended way to do integration testing of tasks is to have a JUnit/TestNG test execute a real (test) build using the tooling API. You can find examples on how to use the tooling API in the samples that ship with the full Gradle distribution.

Ah, that makes sense. And it’ll likely produce results friendly to the CI server as well then. I’ll have to investigate that some and refactor to that. Thanks.

Hi Rob,

You can take a look at https://github.com/alkemist/gradle-test-kit for some inspiration.