How can i specify a given dependency to be available only during the unit test compilation time?

I have a dependency that i need only during the unit test runtime. How can i declare that using gradle configuration?

you mentioned both unit test compilation and test runtime, so depending on exactly which…

dependencies {
    // available during compilation of tests as well as when they run...
    testCompile 'your:dependency:#.#.#'
    
    // available only while tests are running, not compilation...
    testRuntime 'your:dependency:#.#.#'
}

More about dependency configurations