Include integration test results in Jacoco 02/137202/3
authordanielhanrahan <daniel.hanrahan@est.tech>
Fri, 9 Feb 2024 17:40:18 +0000 (17:40 +0000)
committerdanielhanrahan <daniel.hanrahan@est.tech>
Mon, 12 Feb 2024 11:57:57 +0000 (11:57 +0000)
integration-test module is not recording code coverage due to
incorrectly overriding the maven surefire config from parent pom.

Issue-ID: CPS-2086
Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech>
Change-Id: I774c64acedca546f5c01403597bd9f5010de73d2

cps-parent/pom.xml
integration-test/pom.xml
integration-test/src/test/groovy/org/onap/cps/integration/performance/base/PerfTestBase.groovy

index 2e81b00..6e7554b 100644 (file)
@@ -3,7 +3,7 @@
   ============LICENSE_START=======================================================
   Copyright (c) 2021 Pantheon.tech.
   Modifications Copyright (C) 2021 Bell Canada.
-  Modifications Copyright (C) 2021-2023 Nordix Foundation.
+  Modifications Copyright (C) 2021-2024 Nordix Foundation.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
                         <include>**/*Test.java</include> <!-- Just in case of having also "normal" JUnit tests -->
                     </includes>
                     <excludes>
-                        <exclude>**/IT*.java</exclude>
+                        <!-- maven-failsafe-plugin will run performance tests in the integration-test module,
+                             so performance tests will not affect Jacoco coverage (jacoco-report module is configured
+                             to aggregate results from tests run with maven-surefire-plugin only) -->
+                        <exclude>**/*PerfTest.java</exclude>
                     </excludes>
                     <environmentVariables>
                         <!--
index 73998cd..6947a94 100644 (file)
@@ -26,7 +26,6 @@
         <version>3.4.4-SNAPSHOT</version>
         <relativePath>../cps-parent/pom.xml</relativePath>
     </parent>
-
     <modelVersion>4.0.0</modelVersion>
 
     <artifactId>integration-test</artifactId>
         </dependency>
     </dependencies>
 
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-failsafe-plugin</artifactId>
-                <configuration>
-                    <argLine>-Xms512m -Xmx512m</argLine>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <configuration>
-                    <argLine>-Xms512m -Xmx512m</argLine>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-
     <profiles>
+        <!-- Performance tests are run with maven-failsafe-plugin using a separate profile, so they will
+             not affect Jacoco coverage. Heap size is set here to ensure consistent test environment. -->
         <profile>
-            <id>default</id>
-            <activation>
-                <activeByDefault>true</activeByDefault>
-            </activation>
+            <id>include-performance</id>
+            <properties>
+                <failsafeArgLine>-Xms512m -Xmx512m</failsafeArgLine>
+            </properties>
             <build>
                 <plugins>
                     <plugin>
                         <groupId>org.apache.maven.plugins</groupId>
-                        <artifactId>maven-surefire-plugin</artifactId>
+                        <artifactId>maven-failsafe-plugin</artifactId>
                         <configuration>
-                            <excludes>
-                                <exclude>%regex[.*PerfTest.*]</exclude>
-                            </excludes>
+                            <includes>
+                                <include>**/*PerfTest.java</include>
+                            </includes>
                         </configuration>
                     </plugin>
                 </plugins>
             </build>
         </profile>
-        <profile>
-            <id>include-performance</id>
-        </profile>
     </profiles>
 
-
 </project>
index b455e69..ce0aab4 100644 (file)
@@ -21,7 +21,6 @@
 package org.onap.cps.integration.performance.base
 
 import org.onap.cps.integration.base.CpsIntegrationSpecBase
-import org.springframework.util.StopWatch
 
 abstract class PerfTestBase extends CpsIntegrationSpecBase {