Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions CppCoveragePlugin.sln
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29009.5
# Visual Studio Version 17
VisualStudioVersion = 17.3.32929.385
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2D036BFA-5FAC-467B-9648-5B2BBC5B872C}"
ProjectSection(SolutionItems) = preProject
IntegrationTests.testsettings = IntegrationTests.testsettings
UnitTests.testsettings = UnitTests.testsettings
UnitTests.runsettings = UnitTests.runsettings
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VSPackage", "VSPackage\VSPackage.csproj", "{DF742CAB-0446-4867-A437-719390CC028A}"
Expand Down Expand Up @@ -37,4 +36,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1E333D91-8EDB-46BF-8025-24EB9E8DF2EC}
EndGlobalSection
EndGlobal
53 changes: 34 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,76 @@
![](https://github.com/OpenCppCoverage/OpenCppCoveragePlugin/workflows/Unit%20tests/badge.svg)
# OpenCppCoveragePlugin
Official Visual Studio Plugin for OpenCppCoverage
# OpenCppCoveragePlugin for VisualStudio2022
This is a fork of [Official Visual Studio Plugin for OpenCppCoverage](https://github.com/OpenCppCoverage/OpenCppCoveragePlugin).
This works for me. But tests are broken.

**OpenCppCoverage** is an open source code coverage tool for C++ under Windows. You can find more information about this project [here](https://opencppcoverage.codeplex.com/).

This repository contains only the Visual Studio plugin sources.

## Usage

To install and use this plugin, please see the [Visual Studio Gallery page](https://visualstudiogallery.msdn.microsoft.com/f45b8e13-f847-4b3b-92df-984df633b60e).
You can also install the NuGet package **OpenCppCoverage Plugin**.
~~To install and use this plugin, please see the [Visual Studio Gallery page](https://visualstudiogallery.msdn.microsoft.com/f45b8e13-f847-4b3b-92df-984df633b60e).
You can also install the NuGet package **OpenCppCoverage Plugin**.~~

**Documentation is available [here](https://github.com/OpenCppCoverage/OpenCppCoveragePlugin/wiki)**.

For questions, you can create a discussion [here](https://opencppcoverage.codeplex.com/discussions).
If you find a bug, you can create an issue [here](https://opencppcoverage.codeplex.com/workitem/list/basic).
~~For questions, you can create a discussion [here](https://opencppcoverage.codeplex.com/discussions).
If you find a bug, you can create an issue [here](https://opencppcoverage.codeplex.com/workitem/list/basic).~~

## Development

### Compilation
You have 2 Visual Studio solution files but **Visual Studio 2017 is always required**.
Please also make sure you have Visual Studio 2017 **version 15.8.X**.
You have 2 Visual Studio solution files but **Visual Studio 2022 is always required**.
Please also make sure you have Visual Studio 2022 **version 17.3.X**.

#### CppCoveragePlugin.sln
This is the default solution file and it requires only Visual Studio 2017.
This is the default solution file and it requires only Visual Studio 2022.

#### CppCoveragePluginVS2013.sln
**This is a Visual Studio 2017 solution file** but it also requires:
* Visual Studio 2013 Update 5.
* [Microsoft Visual Studio 2013 SDK](https://visualstudiogallery.msdn.microsoft.com/842766ba-1f32-40cf-8617-39365ebfc134/view/). If you have any trouble to install the SDK, [this stack overflow question](https://stackoverflow.com/questions/22949411/visual-studio-2012-install-fails-program-compatibility-mode-is-on/23114542) can help.
* Visual Studio 2015 Update 3 may be required.
~~**This is a Visual Studio 2017 solution file** but it also requires:~~
* ~~Visual Studio 2013 Update 5.~~
* ~~[Microsoft Visual Studio 2013 SDK](https://visualstudiogallery.msdn.microsoft.com/842766ba-1f32-40cf-8617-39365ebfc134/view/). If you have any trouble to install the SDK, [this stack overflow question](https://stackoverflow.com/questions/22949411/visual-studio-2012-install-fails-program-compatibility-mode-is-on/23114542) can help.~~
* ~~Visual Studio 2015 Update 3 may be required.~~

This solution should be used only to generate a plugin compatible with Visual Studio 2013, 2015 and 2017.
~~This solution should be used only to generate a plugin compatible with Visual Studio 2013, 2015 and 2017.~~

#### OpenCppCoverage
You should install the latest version of [OpenCppCoverage](https://github.com/OpenCppCoverage/OpenCppCoverage/releases/tag/release-0.9.7.0):
You should install the latest version of [OpenCppCoverage](https://github.com/OpenCppCoverage/OpenCppCoverage/releases/tag/release-0.9.9.0):
* *OpenCppCoverageSetup-x64-X.X.X.exe*: into *VSPackage\OpenCppCoverage-x64*
* *OpenCppCoverageSetup-x86-X.X.X.exe*: into *VSPackage\OpenCppCoverage-x86*

You can also copy past the binaries from an existing installation into these folders.
Binaries inside *VSPackage\OpenCppCoverage-x86* can be the same as *VSPackage\OpenCppCoverage-x64* (The opposite is not true).

You also should copy msvcp140.dll and vcruntime140.dll from
`C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE`
to
`\your\solution\directory\VSPackage\OpenCppCoverage-x64` and
`\your\solution\directory\VSPackage\OpenCppCoverage-x86`.

You also should copy Newtonsoft.Json.dll from
`C:\Users\YourName\.nuget\packages\newtonsoft.json\13.0.1\lib\net45`
to
`\your\solution\directory\VSPackage\`.

### Run the plugin

* Set *VSPackage* as *StartUp Project*.
* In *VSPackage Properties*, tab *Debug*:
* Select *Start external program* and set value to `C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe` (Update this path if you installed Visual Studio to another location).
* Select *Start external program* and set value to `C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.exe` (Update this path if you installed Visual Studio to another location).
* Add `/RootSuffix Exp` as *Command line arguments*.

If you have an issue when running the plugin, you can try to reset Visual Studio Experimental instance:

`"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VSSDK\VisualStudioIntegration\Tools\Bin\CreateExpInstance.exe" /Reset /VSInstance=15.0 /RootSuffix=Exp`
`"C:\Program Files\Microsoft Visual Studio\2022\Communityy\VSSDK\VisualStudioIntegration\Tools\Bin\CreateExpInstance.exe" /Reset /VSInstance=17.0 /RootSuffix=Exp`

### Run unit tests

You can run the tests with *Test Explorer window*.
To run *VSPackage_IntegrationTests* you need to expand *Solution items* in *Solution Explorer* and set *Active Load and Web Test Settings* for *IntegrationTests.testsettings*. If you have a COM error when running tests, you can select *IntegrationTests.testsettings* file from Visual Studio menu: Test/Test Settings/Select Test Settings File.
For *VSPackage_UnitTests* you need to do the same but with *UnitTests.testsettings*.
~~To run *VSPackage_IntegrationTests* you need to expand *Solution items* in *Solution Explorer* and set *Active Load and Web Test Settings* for *IntegrationTests.testsettings*. If you have a COM error when running tests, you can select *IntegrationTests.testsettings* file from Visual Studio menu: Test/Test Settings/Select Test Settings File.~~

On Visual Studio 2022 *VSPackage_IntegrationTests* is broken because VSIDETestAdapter is deprecated and already erased.

For *VSPackage_UnitTests* you need to do with *UnitTests.runsettings*.

If a test failed, you can try to run it again. You can also reset Visual Studio Experimental instance.
113 changes: 113 additions & 0 deletions UnitTests.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- Configurations that affect the Test Framework -->
<RunConfiguration>
<!-- Use 0 for maximum process-level parallelization. This does not force parallelization within the test DLL (on the thread-level). You can also change it from the Test menu; choose "Run tests in parallel". Unchecked = 1 (only 1), checked = 0 (max). -->
<MaxCpuCount>1</MaxCpuCount>
<!-- Path relative to directory that contains .runsettings file-->
<ResultsDirectory>.\TestResults</ResultsDirectory>

<!-- Omit the whole tag for auto-detection. -->
<!-- [x86] or x64, ARM, ARM64, s390x -->
<!-- You can also change it from the Test menu; choose "Processor Architecture for AnyCPU Projects" -->
<TargetPlatform>x64</TargetPlatform>

<!-- Any TargetFramework moniker or omit the whole tag for auto-detection. -->
<!-- net48, [net40], net6.0, net5.0, netcoreapp3.1, uap10.0 etc. -->
<TargetFrameworkVersion>net472</TargetFrameworkVersion>

<!-- Path to Test Adapters -->
<TestAdaptersPaths>.</TestAdaptersPaths>

<!-- TestSessionTimeout was introduced in Visual Studio 2017 version 15.5 -->
<!-- Specify timeout in milliseconds. A valid value should be greater than 0 -->
<TestSessionTimeout>500000</TestSessionTimeout>

<!-- true or false -->
<!-- Value that specifies the exit code when no tests are discovered -->
<TreatNoTestsAsError>true</TreatNoTestsAsError>
</RunConfiguration>

<!-- Configurations for data collectors -->
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>
<ModulePaths>
<Exclude>
<ModulePath>.*CPPUnitTestFramework.*</ModulePath>
</Exclude>
</ModulePaths>

<!-- We recommend you do not change the following values: -->
<UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
<AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
<CollectFromChildProcesses>True</CollectFromChildProcesses>
<CollectAspDotNet>False</CollectAspDotNet>

</CodeCoverage>
</Configuration>
</DataCollector>

<DataCollector uri="datacollector://microsoft/VideoRecorder/1.0" assemblyQualifiedName="Microsoft.VisualStudio.TestTools.DataCollection.VideoRecorder.VideoRecorderDataCollector, Microsoft.VisualStudio.TestTools.DataCollection.VideoRecorder, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" friendlyName="Screen and Voice Recorder">
<!--Video data collector was introduced in Visual Studio 2017 version 15.5 -->
<Configuration>
<!-- Set "sendRecordedMediaForPassedTestCase" to "false" to add video attachments to failed tests only -->
<MediaRecorder sendRecordedMediaForPassedTestCase="true" xmlns="">
<ScreenCaptureVideo bitRate="512" frameRate="2" quality="20" />​
</MediaRecorder>​
</Configuration>
</DataCollector>

<!-- Configuration for blame data collector -->
<DataCollector friendlyName="blame" enabled="True">
</DataCollector>

</DataCollectors>
</DataCollectionRunSettings>

<!-- Parameters used by tests at run time -->
<TestRunParameters>
<Parameter name="webAppUrl" value="http://localhost" />
<Parameter name="webAppUserName" value="Admin" />
<Parameter name="webAppPassword" value="Password" />
</TestRunParameters>

<!-- Configuration for loggers -->
<LoggerRunSettings>
<Loggers>
<Logger friendlyName="console" enabled="True">
<Configuration>
<Verbosity>quiet</Verbosity>
</Configuration>
</Logger>
<Logger friendlyName="trx" enabled="True">
<Configuration>
<LogFileName>foo.trx</LogFileName>
</Configuration>
</Logger>
<Logger friendlyName="html" enabled="True">
<Configuration>
<LogFileName>foo.html</LogFileName>
</Configuration>
</Logger>
<Logger friendlyName="blame" enabled="True" />
</Loggers>
</LoggerRunSettings>

<!-- Adapter Specific sections -->

<!-- MSTest adapter -->
<MSTest>
<MapInconclusiveToFailed>True</MapInconclusiveToFailed>
<CaptureTraceOutput>false</CaptureTraceOutput>
<DeleteDeploymentDirectoryAfterTestRunIsComplete>False</DeleteDeploymentDirectoryAfterTestRunIsComplete>
<DeploymentEnabled>False</DeploymentEnabled>
<AssemblyResolution>
<Directory path="D:\myfolder\bin\" includeSubDirectories="false"/>
</AssemblyResolution>
</MSTest>

</RunSettings>
Loading