In case anyone comes here based on the Could not find method testCompile() error, by now the more probable cause is that you need to replace the deprecated testCompile by testImplementation.
See What’s the difference between implementation and compile in Gradle?