aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.core.test/src/org/jacoco/core/test/validation
diff options
context:
space:
mode:
authorEvgeny Mandrikov <Godin@users.noreply.github.com>2017-02-27 15:03:44 +0100
committerMarc R. Hoffmann <hoffmann@mountainminds.com>2017-02-27 15:03:44 +0100
commit296f992a80fb545bb3447c8882cf213f56a765bd (patch)
tree1c0e28a70e92dfd8cce5f24feef27f26f3e230eb /org.jacoco.core.test/src/org/jacoco/core/test/validation
parent274577d8ff30202c14868923fc75370510e4e0df (diff)
downloadjacoco-296f992a80fb545bb3447c8882cf213f56a765bd.tar.gz
Exclude enum methods "values" and "valueOf" from reports (#491)
Diffstat (limited to 'org.jacoco.core.test/src/org/jacoco/core/test/validation')
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/EnumImplicitMethodsTest.java39
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/EnumImplicitMethods.java48
2 files changed, 87 insertions, 0 deletions
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/EnumImplicitMethodsTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/EnumImplicitMethodsTest.java
new file mode 100644
index 00000000..ddc1da12
--- /dev/null
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/EnumImplicitMethodsTest.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2017 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Evgeny Mandrikov - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation;
+
+import org.jacoco.core.analysis.ICounter;
+import org.jacoco.core.test.validation.targets.EnumImplicitMethods;
+import org.junit.Test;
+
+/**
+ * Test of an implicit methods and static initializer in enums.
+ */
+public class EnumImplicitMethodsTest extends ValidationTestBase {
+
+ public EnumImplicitMethodsTest() {
+ super(EnumImplicitMethods.class);
+ }
+
+ @Test
+ public void testCoverageResult() {
+ assertLine("classdef", ICounter.FULLY_COVERED);
+ assertLine("customValueOfMethod", ICounter.NOT_COVERED);
+ assertLine("customValuesMethod", ICounter.NOT_COVERED);
+
+ assertLine("const", ICounter.PARTLY_COVERED);
+ assertLine("staticblock", ICounter.FULLY_COVERED);
+ assertLine("super", ICounter.FULLY_COVERED);
+ assertLine("constructor", ICounter.FULLY_COVERED);
+ }
+
+}
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/EnumImplicitMethods.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/EnumImplicitMethods.java
new file mode 100644
index 00000000..aaa5e987
--- /dev/null
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/EnumImplicitMethods.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2017 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Evgeny Mandrikov - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation.targets;
+
+public enum EnumImplicitMethods { // $line-classdef$
+
+ CONST(Stubs.f() ? new Object() : new Object()); // $line-const$
+
+ static {
+ } // $line-staticblock$
+
+ /**
+ * Unlike in {@link Target07 regular classes}, even if enum has explicit
+ * constructor, {@code clinit} method in any case has a reference to the
+ * line of enum definition.
+ */
+ EnumImplicitMethods(Object o) { // $line-super$
+ } // $line-constructor$
+
+ /**
+ * This method should not be excluded from analysis unlike implicitly
+ * created {@link #valueOf(String)} method that refers to the line of enum
+ * definition.
+ */
+ public void valueOf() {
+ } // $line-customValueOfMethod$
+
+ /**
+ * This method should not be excluded from analysis unlike implicitly
+ * created {@link #values()} method that refers to the line of enum
+ * definition.
+ */
+ public void values(Object o) {
+ } // $line-customValuesMethod$
+
+ public static void main(String[] args) {
+ }
+
+}