Add support for method, statement and block context filtering through the following properties: <code>maven.clover.context.block.names</code>, <code>maven.clover.context.method.names</code>, <code>maven.clover.context.method.regexps</code>, <code>maven.clover.context.statement.names</code> and <code>maven.clover.context.statement.regexps</code>.
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@154865 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
1 parent
cdf4581a8c
commit
c84cae6dfb
9 files changed
+295
-2
No files matched your search
+38
-2
@@ -160,6 +160,20 @@
|
||||
|
||||
</j:if>
|
||||
|
||||
<!-- Define method contexts provided by users -->
|
||||
<u:tokenize var="contextMethodNames" delim=",">${maven.clover.context.method.names}</u:tokenize>
|
||||
<u:tokenize var="contextMethodRegexps" delim=",">${maven.clover.context.method.regexps}</u:tokenize>
|
||||
<j:forEach var="contextMethodName" items="${contextMethodNames}">
|
||||
<ant:methodContext name="${contextMethodName}" regexp="${contextMethodRegexps.remove(0)}"/>
|
||||
</j:forEach>
|
||||
|
||||
<!-- Define statement contexts provided by users -->
|
||||
<u:tokenize var="statementMethodNames" delim=",">${maven.clover.context.statement.names}</u:tokenize>
|
||||
<u:tokenize var="statementMethodRegexps" delim=",">${maven.clover.context.statement.regexps}</u:tokenize>
|
||||
<j:forEach var="statementMethodName" items="${statementMethodNames}">
|
||||
<ant:statementContext name="${statementMethodName}" regexp="${statementMethodRegexps.remove(0)}"/>
|
||||
</j:forEach>
|
||||
|
||||
</ant:clover-setup>
|
||||
|
||||
<echo>Now using primary build.compiler : ${build.compiler}</echo>
|
||||
@@ -280,7 +294,15 @@
|
||||
<ant:clover-report>
|
||||
<ant:current outfile="${maven.build.dir}/clover.xml"
|
||||
title="${pom.name} - ${pom.currentVersion}">
|
||||
<ant:format type="xml" orderBy="${maven.clover.orderBy}"/>
|
||||
<ant:format type="xml" orderBy="${maven.clover.orderBy}">
|
||||
|
||||
<!-- Add context filtering -->
|
||||
<j:set var="contextFilters" value="${maven.clover.context.method.names} ${maven.clover.context.statement.names} ${maven.clover.context.block.names}"/>
|
||||
<j:if test="${!empty(contextFilters.trim())}">
|
||||
<ant:setProperty name="filter" value="${contextFilters}"/>
|
||||
</j:if>
|
||||
|
||||
</ant:format>
|
||||
</ant:current>
|
||||
</ant:clover-report>
|
||||
</goal>
|
||||
@@ -299,7 +321,15 @@
|
||||
<ant:current
|
||||
outfile="${cloverReportDirectory}"
|
||||
title="${pom.name} - ${pom.currentVersion}">
|
||||
<ant:format type="html" orderBy="${maven.clover.orderBy}"/>
|
||||
<ant:format type="html" orderBy="${maven.clover.orderBy}">
|
||||
|
||||
<!-- Add context filtering -->
|
||||
<j:set var="contextFilters" value="${maven.clover.context.method.names} ${maven.clover.context.statement.names} ${maven.clover.context.block.names}"/>
|
||||
<j:if test="${!empty(contextFilters.trim())}">
|
||||
<ant:setProperty name="filter" value="${contextFilters}"/>
|
||||
</j:if>
|
||||
|
||||
</ant:format>
|
||||
</ant:current>
|
||||
</ant:clover-report>
|
||||
</goal>
|
||||
@@ -388,6 +418,12 @@
|
||||
<ant:package name="${package}" target="${targets.remove(0)}"/>
|
||||
</j:forEach>
|
||||
|
||||
<!-- Add context filtering -->
|
||||
<j:set var="contextFilters" value="${maven.clover.context.method.names} ${maven.clover.context.statement.names} ${maven.clover.context.block.names}"/>
|
||||
<j:if test="${!empty(contextFilters.trim())}">
|
||||
<ant:setProperty name="filter" value="${contextFilters}"/>
|
||||
</j:if>
|
||||
|
||||
</ant:clover-check>
|
||||
|
||||
</goal>
|
||||
|
||||
@@ -68,3 +68,18 @@ maven.clover.check.target = 50%
|
||||
# clover:check is called
|
||||
# maven.clover.check.packages=my.package1,my.package2
|
||||
# maven.clover.check.targets=10%,80%
|
||||
|
||||
# List of Clover-defined block contexts to filter. Example:
|
||||
# maven.clover.context.block.names = static, method
|
||||
|
||||
# List of user-defined method context names. Example:
|
||||
# maven.clover.context.method.names = name1, name2
|
||||
|
||||
# List of user-defined methods context regexps. Example:
|
||||
# maven.clover.context.method.regexps = regexp1, regexp2
|
||||
|
||||
# List of user-defined statement context names. Example:
|
||||
# maven.clover.context.statement.names = name3, name4
|
||||
|
||||
# List of user-defined statement context regexps. Example:
|
||||
# maven.clover.context.statement.regexps = regexp3, regexp4
|
||||
@@ -0,0 +1,42 @@
|
||||
<!--
|
||||
/*
|
||||
* Copyright 2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
-->
|
||||
<project default="testPlugin"
|
||||
xmlns:util="jelly:util"
|
||||
xmlns:j="jelly:core"
|
||||
xmlns:ant="jelly:ant"
|
||||
xmlns:x="jelly:xml"
|
||||
xmlns:maven="jelly:maven"
|
||||
xmlns:assert="assert">
|
||||
|
||||
<goal name="testPlugin">
|
||||
|
||||
<attainGoal name="clean"/>
|
||||
|
||||
<attainGoal name="clover:test"/>
|
||||
<j:catch var="exception">
|
||||
<attainGoal name="clover:check"/>
|
||||
</j:catch>
|
||||
|
||||
<!-- The test is successful if the total coverage is less than 33.4% -->
|
||||
<j:if test="${empty(exception)}">
|
||||
<ant:fail message="The test coverage should have been lower than 33.4%"/>
|
||||
</j:if>
|
||||
|
||||
</goal>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,26 @@
|
||||
# -------------------------------------------------------------------
|
||||
# Copyright 2005 The Apache Software Foundation.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# -------------------------------------------------------------------
|
||||
|
||||
maven.clover.context.method.names = methodsEndingWith1
|
||||
maven.clover.context.method.regexps = .*1.*
|
||||
|
||||
maven.clover.context.statement.names = ifBlocks
|
||||
maven.clover.context.statement.regexps = .*if.*
|
||||
|
||||
maven.clover.context.block.names = static
|
||||
|
||||
# Test is successful is coverage is <= 33.3%
|
||||
maven.clover.check.target = 33.4%
|
||||
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
/*
|
||||
* Copyright 2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
<project>
|
||||
<extend>${basedir}/../project.xml</extend>
|
||||
<id>testCloverContexts</id>
|
||||
<name>testCloverContexts</name>
|
||||
<build>
|
||||
<sourceDirectory>src/main</sourceDirectory>
|
||||
<unitTestSourceDirectory>src/test</unitTestSourceDirectory>
|
||||
<unitTest>
|
||||
<includes>
|
||||
<include>**/*Test.java</include>
|
||||
</includes>
|
||||
</unitTest>
|
||||
</build>
|
||||
</project>
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package org.apache.maven.clover.test;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
public class Simple
|
||||
{
|
||||
static
|
||||
{
|
||||
System.getProperties();
|
||||
}
|
||||
|
||||
public void someMethod1()
|
||||
{
|
||||
}
|
||||
|
||||
public void someMethodToReduceStatementCoverage()
|
||||
{
|
||||
System.getProperties();
|
||||
}
|
||||
|
||||
public void someMethod2(int i)
|
||||
{
|
||||
if (i == 2)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package org.apache.maven.clover.test;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class SimpleTest extends TestCase
|
||||
{
|
||||
public void testSomeMethod()
|
||||
{
|
||||
Simple simple = new Simple();
|
||||
simple.someMethod1();
|
||||
simple.someMethod2(1);
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,15 @@
|
||||
</properties>
|
||||
<body>
|
||||
<release version="1.8" date="in SVN">
|
||||
<action dev="vmassol" type="add">
|
||||
Add support for method, statement and block context filtering through
|
||||
the following properties:
|
||||
<code>maven.clover.context.block.names</code>,
|
||||
<code>maven.clover.context.method.names</code>,
|
||||
<code>maven.clover.context.method.regexps</code>,
|
||||
<code>maven.clover.context.statement.names</code> and
|
||||
<code>maven.clover.context.statement.regexps</code>.
|
||||
</action>
|
||||
<action dev="vmassol" type="add">
|
||||
Added new <code>clover:check</code> goal that verifies if the
|
||||
test coverage if above a threshold defined by the properties
|
||||
|
||||
@@ -188,6 +188,64 @@
|
||||
N/A
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>maven.clover.context.block.names</td>
|
||||
<td>Yes</td>
|
||||
<td>
|
||||
Comma-separated list of Clover-defined block contexts to filter
|
||||
from the Clover coverage report.
|
||||
Example: <code>maven.clover.context.block.names = static, method</code>.
|
||||
</td>
|
||||
<td>
|
||||
N/A
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>maven.clover.context.method.names</td>
|
||||
<td>Yes</td>
|
||||
<td>
|
||||
Comma-separated list of user-defined method contexts to filter from
|
||||
the Clover coverage report.
|
||||
Example: <code>maven.clover.context.method.names = name1, name2</code>.
|
||||
</td>
|
||||
<td>
|
||||
N/A
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>maven.clover.context.method.regexps</td>
|
||||
<td>Yes</td>
|
||||
<td>
|
||||
Regexps associated with <code>maven.clover.context.method.names</code>.
|
||||
Example: <code>maven.clover.context.method.regexps = regexp1, regexp2</code>.
|
||||
</td>
|
||||
<td>
|
||||
N/A
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>maven.clover.context.statement.names</td>
|
||||
<td>Yes</td>
|
||||
<td>
|
||||
Comma-separated list of user-defined statement contexts to filter from
|
||||
the Clover coverage report.
|
||||
Example: <code>maven.clover.context.statement.names = name3, name4</code>.
|
||||
</td>
|
||||
<td>
|
||||
N/A
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>maven.clover.context.statement.regexps</td>
|
||||
<td>Yes</td>
|
||||
<td>
|
||||
Regexps associated with <code>maven.clover.context.statement.names</code>.
|
||||
Example: <code>maven.clover.context.statement.regexps = regexp3, regexp4</code>.
|
||||
</td>
|
||||
<td>
|
||||
N/A
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</section>
|
||||
</body>
|
||||
|
||||
Reference in new issue
Block a user