# Show test reports when test coverage verification fails

**URL:** <https://discuss.gradle.org/t/show-test-reports-when-test-coverage-verification-fails/34649>\
**Category:** Help/Discuss\
**Created:** [January 23, 2020, 12:33pm UTC](https://discuss.gradle.org/t/show-test-reports-when-test-coverage-verification-fails/34649 "2020-01-23T12:33:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![donalmurtagh](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@donalmurtagh](https://discuss.gradle.org/u/donalmurtagh)\
**Post date:** [January 23, 2020, 12:33pm UTC](https://discuss.gradle.org/t/show-test-reports-when-test-coverage-verification-fails/34649/1 "2020-01-23T12:33:58Z")

</div>

My Gradle build does the following

1. Runs the tests
2. Opens a test report in the browser
3. Opens a test coverage in the browser
4. Verifies that test coverage is at least 80%

The relevant tasks in build.gradle are:

```
task testWithReports {   
  dependsOn 'clean'
  dependsOn 'test'
  dependsOn 'jacocoTestReport'
  dependsOn 'showCoverage'
  dependsOn 'showTestResults'
  dependsOn 'jacocoTestCoverageVerification'
}

jacocoTestReport {
  reports {
    xml.enabled false
    csv.enabled false
    html.destination file("${buildDir}/jacocoHtml")
  }
}

task showCoverage {
  doLast {
    desktop.browse "file:///${buildDir}/jacocoHtml/index.html".toURI()
  }
}

task showTestResults {
  doLast {
    desktop.browse "file:///${buildDir}/junitHtml/index.html".toURI()
  }
}

jacocoTestCoverageVerification {
  violationRules {
    rule {
      limit {
        minimum = 0.8
      }
    }
  }
}

```

If I run `testWithReports` and the `jacocoTestCoverageVerification` subtask fails, the test reports are not opened. Is there a way to define these tasks which ensures that these reports are always opened?
