From c84cae6dfb8b2720065e515021fa63fa7279d9ad Mon Sep 17 00:00:00 2001 From: vmassol Date: Tue, 22 Feb 2005 16:03:19 +0000 Subject: [PATCH] Add support for method, statement and block context filtering through the following properties: maven.clover.context.block.names, maven.clover.context.method.names, maven.clover.context.method.regexps, maven.clover.context.statement.names and maven.clover.context.statement.regexps. git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@154865 13f79535-47bb-0310-9956-ffa450edef68 --- clover/plugin.jelly | 40 ++++++++++++- clover/plugin.properties | 15 +++++ .../plugin-test/testCloverContexts/maven.xml | 42 ++++++++++++++ .../testCloverContexts/project.properties | 26 +++++++++ .../testCloverContexts/project.xml | 34 +++++++++++ .../org/apache/maven/clover/test/Simple.java | 43 ++++++++++++++ .../apache/maven/clover/test/SimpleTest.java | 30 ++++++++++ clover/xdocs/changes.xml | 9 +++ clover/xdocs/properties.xml | 58 +++++++++++++++++++ 9 files changed, 295 insertions(+), 2 deletions(-) create mode 100644 clover/src/plugin-test/testCloverContexts/maven.xml create mode 100644 clover/src/plugin-test/testCloverContexts/project.properties create mode 100644 clover/src/plugin-test/testCloverContexts/project.xml create mode 100644 clover/src/plugin-test/testCloverContexts/src/main/org/apache/maven/clover/test/Simple.java create mode 100644 clover/src/plugin-test/testCloverContexts/src/test/org/apache/maven/clover/test/SimpleTest.java diff --git a/clover/plugin.jelly b/clover/plugin.jelly index 2d7f41b0..7ef371f1 100644 --- a/clover/plugin.jelly +++ b/clover/plugin.jelly @@ -160,6 +160,20 @@ + + ${maven.clover.context.method.names} + ${maven.clover.context.method.regexps} + + + + + + ${maven.clover.context.statement.names} + ${maven.clover.context.statement.regexps} + + + + Now using primary build.compiler : ${build.compiler} @@ -280,7 +294,15 @@ - + + + + + + + + + @@ -299,7 +321,15 @@ - + + + + + + + + + @@ -388,6 +418,12 @@ + + + + + + diff --git a/clover/plugin.properties b/clover/plugin.properties index b98d6eb1..0a035a49 100644 --- a/clover/plugin.properties +++ b/clover/plugin.properties @@ -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 diff --git a/clover/src/plugin-test/testCloverContexts/maven.xml b/clover/src/plugin-test/testCloverContexts/maven.xml new file mode 100644 index 00000000..7d1ec1e7 --- /dev/null +++ b/clover/src/plugin-test/testCloverContexts/maven.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/clover/src/plugin-test/testCloverContexts/project.properties b/clover/src/plugin-test/testCloverContexts/project.properties new file mode 100644 index 00000000..847e912e --- /dev/null +++ b/clover/src/plugin-test/testCloverContexts/project.properties @@ -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% diff --git a/clover/src/plugin-test/testCloverContexts/project.xml b/clover/src/plugin-test/testCloverContexts/project.xml new file mode 100644 index 00000000..5bc8a2a0 --- /dev/null +++ b/clover/src/plugin-test/testCloverContexts/project.xml @@ -0,0 +1,34 @@ + + + + + + ${basedir}/../project.xml + testCloverContexts + testCloverContexts + + src/main + src/test + + + **/*Test.java + + + + diff --git a/clover/src/plugin-test/testCloverContexts/src/main/org/apache/maven/clover/test/Simple.java b/clover/src/plugin-test/testCloverContexts/src/main/org/apache/maven/clover/test/Simple.java new file mode 100644 index 00000000..ddcdcc1c --- /dev/null +++ b/clover/src/plugin-test/testCloverContexts/src/main/org/apache/maven/clover/test/Simple.java @@ -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 + } + } +} \ No newline at end of file diff --git a/clover/src/plugin-test/testCloverContexts/src/test/org/apache/maven/clover/test/SimpleTest.java b/clover/src/plugin-test/testCloverContexts/src/test/org/apache/maven/clover/test/SimpleTest.java new file mode 100644 index 00000000..39d0af23 --- /dev/null +++ b/clover/src/plugin-test/testCloverContexts/src/test/org/apache/maven/clover/test/SimpleTest.java @@ -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); + } +} \ No newline at end of file diff --git a/clover/xdocs/changes.xml b/clover/xdocs/changes.xml index d8851306..a7adbca6 100644 --- a/clover/xdocs/changes.xml +++ b/clover/xdocs/changes.xml @@ -26,6 +26,15 @@ + + Add support for method, statement and block context filtering through + the following properties: + maven.clover.context.block.names, + maven.clover.context.method.names, + maven.clover.context.method.regexps, + maven.clover.context.statement.names and + maven.clover.context.statement.regexps. + Added new clover:check goal that verifies if the test coverage if above a threshold defined by the properties diff --git a/clover/xdocs/properties.xml b/clover/xdocs/properties.xml index b455dfd6..41387c3c 100644 --- a/clover/xdocs/properties.xml +++ b/clover/xdocs/properties.xml @@ -188,6 +188,64 @@ N/A + + maven.clover.context.block.names + Yes + + Comma-separated list of Clover-defined block contexts to filter + from the Clover coverage report. + Example: maven.clover.context.block.names = static, method. + + + N/A + + + + maven.clover.context.method.names + Yes + + Comma-separated list of user-defined method contexts to filter from + the Clover coverage report. + Example: maven.clover.context.method.names = name1, name2. + + + N/A + + + + maven.clover.context.method.regexps + Yes + + Regexps associated with maven.clover.context.method.names. + Example: maven.clover.context.method.regexps = regexp1, regexp2. + + + N/A + + + + maven.clover.context.statement.names + Yes + + Comma-separated list of user-defined statement contexts to filter from + the Clover coverage report. + Example: maven.clover.context.statement.names = name3, name4. + + + N/A + + + + maven.clover.context.statement.regexps + Yes + + Regexps associated with maven.clover.context.statement.names. + Example: maven.clover.context.statement.regexps = regexp3, regexp4. + + + N/A + +