Found 6 relevant articles
-
Complete Guide to Configuring Multi-module Maven with Sonar and JaCoCo for Merged Coverage Reports
This technical article provides a comprehensive solution for generating merged code coverage reports in multi-module Maven projects using SonarQube and JaCoCo integration. Addressing the common challenge of cross-module coverage statistics, the article systematically explains the configuration of Sonar properties, JaCoCo plugin parameters, and Maven build processes. Key focus areas include the path configuration of sonar.jacoco.reportPath, the append mechanism of jacoco-maven-plugin for report merging, and ensuring Sonar correctly interprets cross-module test coverage data. Through practical configuration examples and technical explanations, developers can implement accurate code quality assessment systems that reflect true test coverage across module boundaries.
-
Filtering JaCoCo Coverage Reports with Gradle: A Practical Guide to Excluding Specific Packages and Classes
This article provides an in-depth exploration of how to exclude specific packages and classes when configuring JaCoCo coverage reports in Gradle projects. By analyzing common issues and solutions, it details the implementation steps using the afterEvaluate closure and fileTree exclusion patterns, and compares configuration differences across Gradle versions. Complete code examples and best practices are included to help developers optimize test coverage reports and enhance the accuracy of code quality assessment.
-
Resolving SonarQube Unit Test Coverage Integration Issues with JaCoCo
This technical article provides a comprehensive analysis of common issues where SonarQube fails to properly acquire JaCoCo unit test coverage in Jenkins and Maven environments. Through detailed examination of SonarQube property configurations, JaCoCo plugin settings, and debugging techniques, it offers complete solutions. The article emphasizes correct configuration of key properties including sonar.binaries, sonar.tests, and sonar.jacoco.reportPath, while explaining the diagnostic value of Jenkins console error messages. Comparative analysis of different configuration approaches helps developers quickly identify and resolve coverage report integration problems.
-
Proper Configuration for Excluding Classes and Packages in Maven Jacoco
This article provides an in-depth analysis of correctly configuring exclusion rules in Maven multi-module projects using Jacoco for code coverage testing. It addresses common configuration errors, offers proper XML configuration examples with wildcard usage guidelines, and explains the application of exclusion rules on compiled class file paths. The discussion extends to additional configuration requirements when integrating with SonarQube, helping developers obtain accurate code coverage reports.
-
Code Coverage: Concepts, Measurement, and Practical Implementation
This article provides an in-depth exploration of code coverage concepts, measurement techniques, and real-world applications. Code coverage quantifies the extent to which automated tests execute source code, collected through specialized instrumentation tools. The analysis covers various metrics including function, statement, and branch coverage, with practical examples demonstrating how coverage tools identify untested code paths. Emphasis is placed on code coverage as a quality reference metric rather than an absolute standard, offering a comprehensive framework from tool selection to CI integration.
-
Mocking Logger and LoggerFactory with PowerMock and Mockito for Static Method Testing
This article provides an in-depth exploration of techniques for mocking SLF4J's LoggerFactory.getLogger() static method in Java unit tests using PowerMock and Mockito frameworks, focusing on verifying log invocation behavior rather than content. It begins by analyzing the technical challenges of static method mocking, detailing the use of PowerMock's @PrepareForTest annotation and mockStatic method, with refactored code examples demonstrating how to mock LoggerFactory.getLogger() for any class. The article then discusses strategies for configuring mock behavior in @Before versus @Test methods, addressing issues of state isolation between tests. Furthermore, it compares traditional PowerMock approaches with Mockito 3.4.0+ new static mocking features, which offer a cleaner API via MockedStatic and try-with-resources. Finally, from a software design perspective, the article reflects on the drawbacks of over-reliance on static log testing and recommends introducing explicit dependencies (e.g., Reporter classes) to enhance testability and maintainability.