-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Coverage minima: add more fine-grained control #55
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f20affd
Coverage minima: Add integration tests to check it
kitbellew 86f51a3
Coverage minima: report 100% coverage if min < 100
kitbellew 6f2b217
Coverage minima: add parameter for branch minima
kitbellew 6e10469
Coverage minima: add more fine-grained control
kitbellew File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
invoker.goals=clean scoverage:check site -e -ntp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<parent> | ||
<groupId>it.scoverage-maven-plugin</groupId> | ||
<artifactId>test_coverage_minima</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>module01</artifactId> | ||
<name>Test SCoverage Coverage Minima : Module 1</name> | ||
|
||
</project> |
12 changes: 12 additions & 0 deletions
12
src/it/test_coverage_minima/module01/src/main/scala/pkg01/HelloService1.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package pkg01 | ||
|
||
class HelloService1 | ||
{ | ||
def hello = | ||
{ | ||
"Hello from module 1" | ||
} | ||
|
||
} | ||
|
||
object HelloService1 extends HelloService1 |
14 changes: 14 additions & 0 deletions
14
src/it/test_coverage_minima/module01/src/test/scala/pkg01/HelloServiceTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package pkg01 | ||
|
||
import org.junit.Test; | ||
import org.junit.Assert.assertEquals | ||
|
||
class HelloServiceTest | ||
{ | ||
@Test | ||
def test1() | ||
{ | ||
assertEquals("Hello from module 1", HelloService1.hello) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<parent> | ||
<groupId>it.scoverage-maven-plugin</groupId> | ||
<artifactId>test_coverage_minima</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>module02</artifactId> | ||
<name>Test SCoverage Coverage Minima : Module 2</name> | ||
|
||
</project> |
12 changes: 12 additions & 0 deletions
12
src/it/test_coverage_minima/module02/src/main/scala/pkg01/HelloService1.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package pkg01 | ||
|
||
class HelloService1 | ||
{ | ||
def hello = | ||
{ | ||
"Hello from module 2" | ||
} | ||
|
||
} | ||
|
||
object HelloService1 extends HelloService1 |
12 changes: 12 additions & 0 deletions
12
src/it/test_coverage_minima/module02/src/main/scala/pkg02/HelloService1.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package pkg02 | ||
|
||
class HelloService1 | ||
{ | ||
def hello = | ||
{ | ||
"Hello from module 2" | ||
} | ||
|
||
} | ||
|
||
object HelloService1 extends HelloService1 |
14 changes: 14 additions & 0 deletions
14
src/it/test_coverage_minima/module02/src/test/scala/pkg01/HelloServiceTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package pkg01 | ||
|
||
import org.junit.Test; | ||
import org.junit.Assert.assertEquals | ||
|
||
class HelloServiceTest | ||
{ | ||
@Test | ||
def test1() | ||
{ | ||
assertEquals("Hello from module 2", HelloService1.hello) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<parent> | ||
<groupId>it.scoverage-maven-plugin</groupId> | ||
<artifactId>test_coverage_minima</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>module03</artifactId> | ||
<name>Test SCoverage Coverage Minima : Module 3</name> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>@project.groupId@</groupId> | ||
<artifactId>@project.artifactId@</artifactId> | ||
<configuration> | ||
<aggregate>true</aggregate> | ||
<minimumCoverage>100</minimumCoverage> | ||
<minimumCoverageBranchTotal>100</minimumCoverageBranchTotal> | ||
<minimumCoverageStmtPerPackage>100</minimumCoverageStmtPerPackage> | ||
<minimumCoverageBranchPerPackage>100</minimumCoverageBranchPerPackage> | ||
<minimumCoverageStmtPerFile>100</minimumCoverageStmtPerFile> | ||
<minimumCoverageBranchPerFile>100</minimumCoverageBranchPerFile> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>check</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
12 changes: 12 additions & 0 deletions
12
src/it/test_coverage_minima/module03/src/main/scala/pkg01/HelloService1.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package pkg01 | ||
|
||
class HelloService1 | ||
{ | ||
def hello = | ||
{ | ||
"Hello from module 3" | ||
} | ||
|
||
} | ||
|
||
object HelloService1 extends HelloService1 |
14 changes: 14 additions & 0 deletions
14
src/it/test_coverage_minima/module03/src/test/scala/pkg01/HelloServiceTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package pkg01 | ||
|
||
import org.junit.Test; | ||
import org.junit.Assert.assertEquals | ||
|
||
class HelloServiceTest | ||
{ | ||
@Test | ||
def test1() | ||
{ | ||
assertEquals("Hello from module 3", HelloService1.hello) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>it.scoverage-maven-plugin</groupId> | ||
<artifactId>integration_tests_parent</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<relativePath>../integration_tests_parent/pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>test_coverage_minima</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>pom</packaging> | ||
<name>Test Scoverage coverage minima</name> | ||
<description>Test Scoverage coverage minima</description> | ||
|
||
<properties> | ||
<scala.compat.version>2.13</scala.compat.version> | ||
<scala.minor.version>12</scala.minor.version> | ||
</properties> | ||
|
||
<modules> | ||
<module>module01</module> | ||
<module>module02</module> | ||
<module>module03</module> | ||
</modules> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>net.alchim31.maven</groupId> | ||
<artifactId>scala-maven-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>@project.groupId@</groupId> | ||
<artifactId>@project.artifactId@</artifactId> | ||
<configuration> | ||
<aggregate>true</aggregate> <!-- for aggregated report --> | ||
<minimumCoverage>95</minimumCoverage> | ||
<minimumCoverageBranchTotal>90</minimumCoverageBranchTotal> | ||
<minimumCoverageStmtPerPackage>90</minimumCoverageStmtPerPackage> | ||
<minimumCoverageBranchPerPackage>85</minimumCoverageBranchPerPackage> | ||
<minimumCoverageStmtPerFile>85</minimumCoverageStmtPerFile> | ||
<minimumCoverageBranchPerFile>80</minimumCoverageBranchPerFile> | ||
<failOnMinimumCoverage>false</failOnMinimumCoverage> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>check</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
def checkModule(logText, module, coverageLog) { | ||
assert new File(basedir, module + "/target/scoverage.xml").exists() | ||
assert new File(basedir, module + "/target/site/scoverage/index.html").exists() | ||
def entry = logText.find { | ||
it.startsWith("scoverage") && | ||
it.contains(":check (default-cli) @ " + module + " ---\n") | ||
} | ||
assert entry != null | ||
assert entry.endsWith(" @ " + module + " ---" + coverageLog.replaceAll("\r\n", "\n") + "[INFO] ") | ||
} | ||
|
||
try { | ||
// check coverage minima | ||
def logText = (new File(basedir, "build.log")).text.replaceAll("\r\n", "\n").split(/\n\[INFO\] \-\-\- /) | ||
|
||
checkModule(logText, "module01", | ||
""" | ||
|[INFO] Coverage is 100%: Statement:Total! | ||
|[INFO] Coverage is 100%: Branch:Total! | ||
|""".stripMargin() | ||
) | ||
checkModule(logText, "module02", | ||
""" | ||
|[ERROR] Coverage is below minimum [50.00% < 95.00%]: Statement:Total | ||
|[INFO] Coverage is 100%: Branch:Total! | ||
|[ERROR] Coverage is below minimum [0.00% < 90.00%]: Statement:Package:pkg02 | ||
|[ERROR] Coverage is below minimum [0.00% < 85.00%]: Branch:Package:pkg02 | ||
|[ERROR] Coverage is below minimum [0.00% < 85.00%]: Statement:File:HelloService1.scala | ||
|[ERROR] Coverage is below minimum [0.00% < 80.00%]: Branch:File:HelloService1.scala | ||
|""".stripMargin() | ||
) | ||
checkModule(logText, "module03", | ||
""" | ||
|[INFO] Coverage is 100%: Statement:Total! | ||
|[INFO] Coverage is 100%: Branch:Total! | ||
|""".stripMargin() | ||
) | ||
|
||
return true | ||
|
||
} catch (Throwable e) { | ||
e.printStackTrace() | ||
return false | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome tests! Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you added the tests, i just duplicated :)