Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@johnrengelman
Created December 29, 2014 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnrengelman/a497cc558022d2cb9457 to your computer and use it in GitHub Desktop.
Save johnrengelman/a497cc558022d2cb9457 to your computer and use it in GitHub Desktop.
Injected Gradle Task
class MyTask extends DefaultTask {
@Inject
FileResolver fileResolver
@TaskAction
public void action() {
//...
}
}
class MyTaskSpec extends Specification {
def 'test task'() {
given:
def task = project.tasks.myTask
task.fileResolver = Mock(FileResolver)
when:
//...
then:
//...
}
}
@jnorthr
Copy link

jnorthr commented Dec 30, 2014

just lovely - thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment