-
Notifications
You must be signed in to change notification settings - Fork 385
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
[BUG] Getting warning "coverage.cobertura.xml was not found" while publishing unit-test result #1704
Comments
Please use Diag option and add the log file e.g. We use this in coverlet CI for troubleshooting. We are not using .runsetting file. Please share target framework information of unit test project. Please run test without using |
Below are the configuration we use for the test project:
If I am removing --logger "trx;LogFileName=TestApp.trx" then it's not producing any trx file which I need to publish. Also there are multiple projects in that solution we to change the LogFileName as well. |
Sorry, I did not add the .runsetting configuration for trx logger. <LoggerRunSettings>
<Loggers>
<Logger friendlyName="trx" enabled="True">
<Configuration>
<LogFileName>TestApp.trx</LogFileName>
</Configuration>
</Logger>
</Loggers>
</LoggerRunSettings> Alternatively you can also use I still think this is a configuration issue. Maybe it is better to avoid .runsettings file for the tests using dynamic test result names. Maybe you should also use coverlet.msbuild because there is a nice blue print for a build pipeline the coverlet git project. |
Yes I don't think this logger runsetting is different from the command I use. If I am removing coverlet --collect and --settings parameters, the trx file is giving expected output. But after adding coverlet is modifying the .trx file. Still I am surprised why coverlet is modifying the test results file. |
coverlet does not modify test results. Test results are created with VSTest.Console.exe and maybe something is missing in runsettings configuration file. https://learn.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file?view=vs-2022 |
Then why TestApp.trx file has below entry: <CollectorDataEntries>
<Collector agentName="Agent00002T" uri="datacollector://microsoft/CoverletCodeCoverage/1.0" collectorDisplayName="XPlat code coverage">
<UriAttachments>
<UriAttachment>
<A href="Agent00002T\coverage.cobertura.xml"></A>
</UriAttachment>
</UriAttachments>
</Collector>
</CollectorDataEntries> I have shared the commands and runsetting file which are being used. |
Looks like the test results are not reflected in the trx file in your environment. I used a repo of another issue and got this results. content of TestApp.trx: <?xml version="1.0" encoding="utf-8"?>
<TestRun id="e823f4d7-16c8-4dc3-a1a5-a23afdd0dcb1" name="bertk@LAPTOP-BERT 2024-10-03 09:06:51" runUser="LAPTOP-BERT\bertk" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
<Times creation="2024-10-03T09:06:51.7254173+02:00" queuing="2024-10-03T09:06:51.7254178+02:00" start="2024-10-03T09:06:49.1711859+02:00" finish="2024-10-03T09:06:51.7303545+02:00" />
<TestSettings name="default" id="938d9e56-4f11-4eb7-a4f0-46922a07f42f">
<Deployment runDeploymentRoot="bertk_LAPTOP-BERT_2024-10-03_09_06_51" />
</TestSettings>
<Results>
<UnitTestResult executionId="6ea6c19c-5b61-488f-86c6-e8e7c5632e5e" testId="8ee823ad-9cd6-033b-c5c3-1267f93a66f4" testName="GetObject_Generic_NotNull" computerName="LAPTOP-BERT" duration="00:00:00.0078380" startTime="2024-10-03T09:06:51.2370548+02:00" endTime="2024-10-03T09:06:51.2448483+02:00" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" outcome="Passed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="6ea6c19c-5b61-488f-86c6-e8e7c5632e5e" />
<UnitTestResult executionId="596d367a-3167-480c-8b82-36e525fd07a1" testId="9f039ce5-05b4-0335-0d1d-8c0743812357" testName="GetObject_Regular_NotNull" computerName="LAPTOP-BERT" duration="00:00:00.0001900" startTime="2024-10-03T09:06:51.2459357+02:00" endTime="2024-10-03T09:06:51.2461265+02:00" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" outcome="Passed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="596d367a-3167-480c-8b82-36e525fd07a1" />
</Results>
<TestDefinitions>
<UnitTest name="GetObject_Regular_NotNull" storage="c:\github\coverlet-issue-1691\coverletgenericissue.test\bin\debug\net8.0\coverletgenericissue.test.dll" id="9f039ce5-05b4-0335-0d1d-8c0743812357">
<Execution id="596d367a-3167-480c-8b82-36e525fd07a1" />
<TestMethod codeBase="C:\GitHub\coverlet-issue-1691\CoverletGenericIssue.Test\bin\Debug\net8.0\CoverletGenericIssue.Test.dll" adapterTypeName="executor://nunit3testexecutor/" className="CoverletGenericIssue.Test.Tests" name="GetObject_Regular_NotNull" />
</UnitTest>
<UnitTest name="GetObject_Generic_NotNull" storage="c:\github\coverlet-issue-1691\coverletgenericissue.test\bin\debug\net8.0\coverletgenericissue.test.dll" id="8ee823ad-9cd6-033b-c5c3-1267f93a66f4">
<Execution id="6ea6c19c-5b61-488f-86c6-e8e7c5632e5e" />
<TestMethod codeBase="C:\GitHub\coverlet-issue-1691\CoverletGenericIssue.Test\bin\Debug\net8.0\CoverletGenericIssue.Test.dll" adapterTypeName="executor://nunit3testexecutor/" className="CoverletGenericIssue.Test.Tests" name="GetObject_Generic_NotNull" />
</UnitTest>
</TestDefinitions>
<TestEntries>
<TestEntry testId="8ee823ad-9cd6-033b-c5c3-1267f93a66f4" executionId="6ea6c19c-5b61-488f-86c6-e8e7c5632e5e" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" />
<TestEntry testId="9f039ce5-05b4-0335-0d1d-8c0743812357" executionId="596d367a-3167-480c-8b82-36e525fd07a1" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" />
</TestEntries>
<TestLists>
<TestList name="Results Not in a List" id="8c84fa94-04c1-424b-9868-57a2d4851a1d" />
<TestList name="All Loaded Results" id="19431567-8539-422a-85d7-44ee4e166bda" />
</TestLists>
<ResultSummary outcome="Completed">
<Counters total="2" executed="2" passed="2" failed="0" error="0" timeout="0" aborted="0" inconclusive="0" passedButRunAborted="0" notRunnable="0" notExecuted="0" disconnected="0" warning="0" completed="0" inProgress="0" pending="0" />
<Output>
<StdOut>NUnit Adapter 4.2.0.0: Test execution started
Running all tests in C:\GitHub\coverlet-issue-1691\CoverletGenericIssue.Test\bin\Debug\net8.0\CoverletGenericIssue.Test.dll
NUnit3TestExecutor discovered 2 of 2 NUnit test cases using Current Discovery mode, Non-Explicit run
NUnit Adapter 4.2.0.0: Test execution complete
</StdOut>
</Output>
<CollectorDataEntries>
<Collector agentName="LAPTOP-BERT" uri="datacollector://microsoft/CoverletCodeCoverage/1.0" collectorDisplayName="XPlat code coverage">
<UriAttachments>
<UriAttachment>
<A href="LAPTOP-BERT\coverage.cobertura.xml"></A>
</UriAttachment>
</UriAttachments>
</Collector>
</CollectorDataEntries>
</ResultSummary>
</TestRun> Please check test execution for warnings and errors. Tip use diagnostic logging: |
Thank you @Bertk for putting effort to look into the issue. It's generating three log files: TestWebApi.log, TestWebApi.datacollector.24-10-03_12-21-25_19621_1.log, TestWebApi.host.24-10-03_12-22-43_98717_12.log TestWebApi.datacollector.24-10-03_12-21-25_19621_1.log
TestWebApi.host.24-10-03_12-22-43_98717_12.log
|
Please execute the test project using following steps:
Also the test project should be updated (test should run everywhere):
Maybe you can share the csproj file for the test project or you compare it by yourself with the test project from the repo. |
Describe the bug
I am using below dotnet test command to run unit-test and collect code coverage. While publishing the unit-test result using PublishTestResults@2 task getting "coverage.cobertura.xml was not found" warning. When I checked the .trx file which contain unit-test result there is a entry for CollectorDataEntries which is causing this.
To Reproduce
Use below dotnet command
dotnet test TestApp.Tests.csproj --logger "trx;LogFileName=TestApp.trx" --collect:"XPlat Code Coverage" --settings "..\coverlet.runsettings"
coverlet.runsettings
Publish unit-test result using task: PublishTestResults@2
Expected behavior
Code coverage should not interfere with the unit-test result (.trx) file
Actual behavior
Unit-test result file has entry like below:
Configuration (please complete the following information):
Please provide more information on your .NET configuration:
* Which coverlet package and version was used? 6.0.2
* Which version of .NET is the code running on? net6.0-windows x86
* What OS and version, and what distro if applicable? Windows 10
* What is the architecture (x64, x86, ARM, ARM64)? .Net x86
* Do you know whether it is specific to that configuration? No
The text was updated successfully, but these errors were encountered: