Hi,
There seems to be a bug at least since Gradle v1.11.
I have to use a file (i.e. load it if it was not already loaded before) in getMessage() of a custom-exception. This exception is thrown in the method under test. With Gradle v1.10 it worked fine. Since v1.11 the file is not found in the classpath when I try to load it in getMessage().
My build.gradle-file looks as simple as that:
apply plugin: 'java'
sourceCompatibility = 1.7
version = '1.0'
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
}
test{
ignoreFailures = true
testLogging {
//
exceptionFormat "full"
}
}
I just executed:
gradle test
(tested with v1.9, v1.10, v1.11, v1.12, v2.2, v2.2.1)
I have provided a Java-testcase here: http://gist.github.com/fortySixAnd2/a032da56acc2d5c7e116
MyClassTest.java is the test-class and the resource/file is loaded in MyLogWrapper.java which is invoked due to an exception in MyClass. Of course this is simplified example and it looks a little bit strange, but you can reproduce the issue easily.
First I thought there is only 1 issue, but now I think there are 2 issues with Gradle since v1.11:
1st issue - as described before)
when I use ignoreFailure=true and testlogging.exceptionFormat ‘short’, I see in the stacktrace of the test-report that my file wasn’t found. => gradle output: BUILD SUCCESSFUL (since ignoreFailure = true)
2nd issue)
when I use ignoreFailure=true and testlogging.exceptionFormat ‘full’, an exception occurs in the gradle code, no test-report will be generated and gradle output is BUILD FAILED
----- with Gradle v1.10 and also in IntelliJ/Eclipse (i.e. with the IDE JUnit-Runner) I get the expected result: my file was found and MyException is in the stacktrace with exception-message ‘someMessage’ and BUILD SUCCESSFUL (since ignoreFailure = true)
Are there any workarounds for these issues in Gradle v1.11 (or newer)?
Thanks & best regards, Manuel