Question

Is there some kind of tool for testing gradle scripts? Like JUnit is for testing Java code.
I would like to test my build.gradle script in way to see if it works properly, but would not like to do changes to the development repository (like commiting somethnig, adding test tags and so on).

Is there a way to do such thing, in lets call it, "transaction" manner, as if to do changes, see if it is doing as I intended and then rollback it.

Or do you recommend to mock my repository and all other needed data (something like staging only for my build script testing) and then do my things there?
What is the best practice for doing this?

Please take into consideration that I am gradle newbie. :)

Thanks in advance for any kind of advice/help.
mismas

Was it helpful?

Solution

There is no single purpose tool for this. OTOH there are various possibilities how to test your code. If your build logic is in buildSrc project - http://www.gradle.org/docs/current/userguide/organizing_build_logic.html#sec:build_sources - you can put your testing code there. Of course you have to decide how to test your code to avoid interaction like repository changes.

You can take a look at Gradle codebase. There are plenty of integration tests where you can find ideas. Aside from unittest it is likely you will want to use Gradle Tooling API to control build started from your tests.

OTHER TIPS

More recent versions of Gradle ship with TestKit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top