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