|
| 1 | +package org.scoverage |
| 2 | + |
| 3 | +import static org.hamcrest.number.IsCloseTo.closeTo |
| 4 | +import org.junit.Test |
| 5 | + |
| 6 | +import static org.junit.Assert.assertThat |
| 7 | + |
| 8 | +class SeparateTestsAcceptanceTest extends AcceptanceTestUtils { |
| 9 | + |
| 10 | + private void testSeparate(boolean useAnt) throws Exception { |
| 11 | + File projectDir = new File('src/test/separate-tests') |
| 12 | + File subprojectDir = new File(projectDir, 'a') |
| 13 | + File testsSubprojectDir = new File(projectDir, 'a-tests') |
| 14 | + |
| 15 | + def build = setupBuild(projectDir, useAnt) |
| 16 | + build.forTasks('clean', 'reportScoverage').run() |
| 17 | + |
| 18 | + // ensure report is generated in base project ... |
| 19 | + def indexHtml = new File(reportDir(subprojectDir), 'index.html') |
| 20 | + checkFile('an index HTML file', indexHtml, true) |
| 21 | + |
| 22 | + // ... but not in test project ... |
| 23 | + def testsIndexHtml = new File(reportDir(testsSubprojectDir), 'index.html') |
| 24 | + checkFile('an index HTML file', testsIndexHtml, false) |
| 25 | + |
| 26 | + // ... and 'Hello.scala' is present there ... |
| 27 | + def helloHtml = new File(reportDir(subprojectDir), 'src/main/scala/hello/Hello.scala.html') |
| 28 | + checkFile('Hello.scala html file', helloHtml, true) |
| 29 | + |
| 30 | + // ... and both statement and branch coverage is 100% |
| 31 | + def branchCoverage = coverage(reportDir(subprojectDir), CoverageType.Branch) |
| 32 | + def statementCoverage = coverage(reportDir(subprojectDir), CoverageType.Statement) |
| 33 | + assertThat('Branch coverage should be 100%, was ' + branchCoverage, branchCoverage, closeTo(100.0, 1.0)) |
| 34 | + assertThat('Statement coverage should be 100%, was ' + statementCoverage, statementCoverage, closeTo(100.0, 1.0)) |
| 35 | + } |
| 36 | + |
| 37 | + @Test |
| 38 | + public void testSeparateTestsWithAnt() throws Exception { |
| 39 | + testSeparate(true) |
| 40 | + } |
| 41 | + |
| 42 | + @Test |
| 43 | + public void testSeparateTestsWithZinc() throws Exception { |
| 44 | + testSeparate(false) |
| 45 | + } |
| 46 | +} |
0 commit comments