Are you tired of guessing which areas of your code need improvements? Do you want to make sure your software is as reliable as possible? Look no further than Visual Studio Enterprise’s Code Coverage feature. With the latest updates to the Code Coverage Results window, analysing your code’s coverage has never been easier or more insightful. Not only does VS Enterprise support multiple report formats, but now it also includes enhanced report merging capabilities to give you even more consolidated coverage data. In this blog, we’ll dive deeper into these exciting updates and explore how they can benefit your software development process.

Advanced Code Coverage Features in Visual Studio Enterprise 2022

Support for Additional Report Formats

Visual Studio Enterprise 2022 has expanded its capabilities to include support for more report formats. This addition ensures that developers have the flexibility to work with a variety of coverage data types, enabling a more seamless integration into existing workflows and tools. The feature caters to diverse project needs and enhances compatibility across different platforms and technologies.

Enhanced Report Merging

The new version of Visual Studio Enterprise enhances the process of merging coverage reports. This improvement ensures that data from multiple test runs can be combined more effectively, providing a comprehensive overview of the application’s code coverage. This feature is particularly useful for teams working on large projects or in continuous integration environments, where tests are run frequently and in various configurations.

Performance Enhancements

Recognizing the importance of efficiency in software development, Visual Studio Enterprise 2022 has introduced significant performance enhancements specifically targeted at the Code Coverage Results window. These enhancements minimise the time required to generate, load, and display coverage reports, thereby speeding up the development cycle and enabling developers to focus more on coding and less on waiting for results.

Code Coverage Views

This feature allows users to navigate and understand their code coverage results easily through an improved user interface. The Code Coverage Results window now offers more detailed and customizable views, making it simpler for developers to identify untested code and understand coverage distribution. This improvement aims to streamline the process of analysing code coverage, allowing for quicker identification of high-risk areas that need additional testing.

Enhanced Code Coverage Functionality

Binary Format Support

Visual Studio Enterprise 2022 now supports the Binary format for coverage reports, using the file extension .coverage. This format is a Microsoft-specific binary format designed for efficient processing and storage of code coverage data. It serves as the default option, optimised for performance and compatibility within the Microsoft ecosystem.

Cobertura Format Support

In addition to proprietary formats, Visual Studio Enterprise 2022 has introduced support for the Cobertura format, identifiable by the .cobertura.xml file extension. This format is widely used in the Java development community and allows for easier integration and report sharing between projects that utilise different programming languages and development environments.

XML Format Support

The tool also offers support for a generic XML format, with reports saved as .xml files. This Microsoft XML format is designed to be easily readable and accessible, enabling developers to manually inspect coverage data or process it using custom tools.

CoverageXml Format Support

Another variation of the XML format supported by Visual Studio Enterprise 2022 is the CoverageXml format, with file extension .coveragexml. Similar to the generic XML format, this Microsoft XML format provides a structured and straightforward way to view and analyse code coverage data, ensuring developers have the necessary tools to maintain high code quality.

Format Conversion

Visual Studio Enterprise 2022 allows developers to convert coverage reports into any of the supported formats. This flexibility ensures that regardless of the initial format in which a coverage report is generated, it can be easily transformed to fit different needs or requirements. For example, a report initially generated in the Binary format can be converted to the Cobertura or XML formats, facilitating broader compatibility and easier data sharing.

Streamlined Report Merging in Visual Studio Enterprise

Enhanced Merging Technique

Visual Studio Enterprise has improved the way it merges code coverage reports. The upgraded algorithm now intelligently combines reports from multiple projects, provided they share the same source code. This development marks a significant step forward in simplifying coverage analysis.

Unified Project Representation

In scenarios where a single project is aimed at different frameworks, Visual Studio Enterprise’s new merging strategy ensures it appears as a singular item within the merged report. Coverage data from these various frameworks are aggregated, offering a consolidated view of the project’s code coverage.

Comparison Between Versions

Between Visual Studio Enterprise versions 17.5 and 17.9, there has been a notable evolution in the report merging functionality. Visual Studio Enterprise 17.5 displayed the old merging method via an image labelled “Image old merge”, while version 17.9 showcases the enhanced merging capabilities through “Image new merge”, indicating a clearer, more aggregated approach to coverage data representation.

Detailed Merge Examples

For those seeking a comprehensive understanding of how the improved report merging operates, Visual Studio Enterprise provides a complete example under “See merge reports scenario”. This example offers a deep dive into the practical applications of the new merging logic, demonstrating its effectiveness in streamlining coverage analysis across multiple project configurations.

Performance and Visualization in Code Coverage

Significant Speed Improvements in Report Operations

Visual Studio Enterprise has made substantial progress in the speed of report operations, particularly in report merging and opening. The latest version showcases remarkable improvements in efficiency, making the development process faster and more streamlined.

Report Opening Time Comparison

A comparison across different versions of Visual Studio Enterprise illustrates the significant reduction in time taken to open a report. For instance, while Version 16.5 required 54 seconds, Version 17.9 has brought this down dramatically to just 5 seconds, showcasing a major leap in performance.

Enhanced Efficiency in Report Merging

Similarly, the time it takes to merge reports has seen a drastic reduction. Where Version 17.0 took 47 seconds for report merging, Version 17.9 has reduced this time to 6 seconds, indicating a major improvement in processing speed.

Innovations in Coverage Views

Visual Studio Enterprise has added new views within the coverage window, allowing developers to analyse coverage data from various perspectives. These enhancements aim to enrich the developer’s experience by providing more insightful and accessible coverage information.

Introduction of Margin Glyphs for Coverage

A novel feature in the form of margin glyphs has been introduced, offering a visual method to identify code coverage in the editor. Solid rectangles represent fully covered lines, striped rectangles signify partially covered lines, and open rectangles denote uncovered lines, providing a quick, at-a-glance understanding of coverage status.

Comparing Line Colouring and Margin Glyphs

The traditional method of line colouring to indicate code coverage can now be complemented with margin glyphs. This new addition offers a different way to visualise code coverage, enhancing the overall user experience by providing options for how coverage data is represented in the IDE.

Guidance on Enabling Code Coverage Colouring

For developers interested in exploring different ways to visualise code coverage, instructions are available on how to switch between line colouring and the new margin glyphs, allowing for customization according to personal preference or project requirements.

Code Coverage Analysis with Source View

Introduction of Source View

Source View enhances the code coverage feature by displaying coverage data based on the directory and file structure. This is distinct from the traditional namespace, class, and method structure representation, focusing instead on aggregating coverage information at the file level.

Utility for C++ Projects

This view is particularly valuable for projects involving C++ code, where unit test projects may rely on static libraries. Source View’s approach facilitates a more cohesive analysis of code coverage across various components of a project, especially in complex C++ environments.

Combining Coverage Across Test Projects

In the project view, each unit test project typically displays coverage data solely for the code executed within its own tests. Source View, however, amalgamates coverage data from all related test projects, offering a comprehensive overview of the code coverage achieved collectively.

Visual Comparison Between Views

The distinction between the Project View (the default setting) and Source View is visually represented through static images in the Visual Studio interface. These images clearly differentiate how coverage data is organised and presented in each view, making it easier for users to select the view that best meets their needs.

Sample Report Type View Available

For developers interested in exploring the capabilities and benefits of Source View in more depth, a complete sample is available under the report type view section. This sample provides practical insights into how Source View can be leveraged to enhance code coverage analysis.

Code Coverage Reporting Features

Changeset Report

This report filters the coverage report and displays coverage statistics only for the changes made in the current local git branch. It helps developers identify the coverage status of their own changes and improve code coverage for new code.

Full Report (default)

This is the default report that shows the complete coverage report, including all code coverage information.

Search

The code coverage results window now includes a search feature. You can use different search parameters to filter your report and find specific information. For example, you can search for methods where block coverage is less than 80%.

Conclusion

Developers in Visual Studio Enterprise 2022 can seamlessly mix views within the Code Coverage feature. For example, they can filter to display methods with <80% block coverage in the current branch, with results reflected in coverage windows and the code editor. This functionality provides valuable code reliability insights, supported by enhanced report formats, improved merging, and performance enhancements. Customizable views enable easy analysis of coverage data, with support for binary, Cobertura, XML, and CoverageXml formats ensuring compatibility. Efficient report merging and optimised performance contribute to enhanced development speed and productivity. Anticipated innovations promise ongoing improvements in performance, visualisation, and coverage analysis, empowering developers further.

Let's Drive Innovation Together

Visual Studio Enterprise 2022's Code Coverage feature allows seamless mixing of views for in-depth code reliability insights, enhanced reporting, and improved performance.