-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable code coverage when "Code Coverage;arg1=val1;arg2=val2" is provided in cli #3172
Conversation
e.g. Input: --collect:"Code Coverage;CLRIEInstrumentationNetCore=true;CLRIEInstrumentationNetFramework=false" Output: <DataCollector friendlyName="Code Coverage" enabled="True"> <Configuration> <CLRIEInstrumentationNetCore>true</CLRIEInstrumentationNetCore> <CLRIEInstrumentationNetFramework>false</CLRIEInstrumentationNetFramework> </Configuration> </DataCollector>
…code-coverage build 20211111.1 Microsoft.Internal.CodeCoverage From Version 17.1.0-beta.21560.1 -> To Version 17.1.0-beta.21561.1
…d-8f377d0f6c72' into dev/fhnaseer/cc-commandline-config
…llowing command, dotnet test --collect:"Code Coverage;arg1=val1;arg2=val2"
@@ -368,7 +368,12 @@ private List<string> AddArgs() | |||
{ | |||
foreach (var arg in this.VSTestCollect) | |||
{ | |||
if (arg.Equals("Code Coverage", StringComparison.OrdinalIgnoreCase)) | |||
// Argument value could be CodeCoverage;a=b;c=d. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Argument value could be CodeCoverage;a=b;c=d. | |
// Argument value could be 'Code Coverage;a=b;c=d'. |
// Split arg with ; and compare with the first token. | ||
var tokens = arg.Split(';'); | ||
|
||
if (arg.Equals("Code Coverage", StringComparison.OrdinalIgnoreCase) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe better to have const string with value = "Code Coverage" for correctness. If someone changes the value in future we will not get misspelling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Hello @fhnaseer! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
@@ -20,6 +20,7 @@ public class VSTestTask : Task, ICancelableTask | |||
private VSTestForwardingApp vsTestForwardingApp; | |||
|
|||
private const string vsTestAppName = "vstest.console.dll"; | |||
private const string CodeCovergaeString = "Code Coverage"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit : misspelling
private const string CodeCovergaeString = "Code Coverage"; | |
private const string CodeCoverageString= "Code Coverage"; |
This will enable code coverage for the given command and will also append testAdapterPath to child dotnet process.
dotnet test --collect:"Code Coverage;arg1=val1"
will call
"dotnet" exec vstest.console.dll D:\TestProject\bin\Debug\net6.0\TestProject.dll --collect:"Code Coverage;arg1=val1" --testAdapterPath:D:\NuGetFeed\microsoft.codecoverage\16.9.4\build\netstandard1.0\