admin管理员组文章数量:1200364
I want to verify if my Gradle build file has specific properties. For example, certain tasks are enabled, and specific plugins are present. Is there a recommended way to write such test?
I want to verify if my Gradle build file has specific properties. For example, certain tasks are enabled, and specific plugins are present. Is there a recommended way to write such test?
Share Improve this question asked Jan 22 at 12:39 pixelpixel 26.4k39 gold badges166 silver badges283 bronze badges 1- 1 I've done similar things to check for preconditions on my build by creating a custom task and fail the build if the precondition is not met. Not sure this would fit your requirement though. – Augusto Commented Jan 22 at 13:45
1 Answer
Reset to default 1Extract any meaningful code from your build file into a plugin and test the plugin within a sample Gradle project that applies that plugin. There you can make whatever assertions you like with the sample project.
Gradle provide instructions on writing plugins plus a suite of tools for testing plugins.
Additionally, if there is any code that it doesn't make sense to extract into a plugin you could make runtime assertions at the end of the build (probably within a Project.afterEvaluate()
hook) so that it will fail fast in the event any expected conditions are not met.
本文标签: unit testingHow to write a test for buildgradlektsStack Overflow
版权声明:本文标题:unit testing - How to write a test for build.gradle.kts? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738563798a2099750.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论