Skip to content

Instantly share code, notes, and snippets.

@voghDev
Created May 21, 2019 10:25
Show Gist options
  • Save voghDev/1f3e6066b007146c630946215b67d3da to your computer and use it in GitHub Desktop.
Save voghDev/1f3e6066b007146c630946215b67d3da to your computer and use it in GitHub Desktop.
createTestResources method to configure MockMaker for Android Kotlin projects. Compatible with Gradle 5+
task createTestResources {
description = "Allows Mocking non-final classes and data classes in a Kotlin project"
doLast {
def mockMakerFile = new File("$projectDir/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker")
if (System.env.MOCK_MAKER != null) {
logger.info("Using MockMaker ${System.env.MOCK_MAKER}")
mockMakerFile.parentFile.mkdirs()
mockMakerFile.createNewFile()
mockMakerFile.write(System.env.MOCK_MAKER)
} else {
logger.info("Using default MockMaker")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment