Issue generating a sonarscanner compatible trx file in commandline

  Kiến thức lập trình

I have a .net Framework project with a DDEF.Tests project in it.
The Tests are written in Nunit.
I can run the tests from Visual Studio without any issues.
When I build the project it generates the DDEF.Tests.dll file correctly. Using ILDASM, I confirmed that the generated dll identifies the [Test] Attribute in my created functions.

I also checked Package References in DDEF.Tests.csproj.

    <PackageReference Include="NUnit" Version="3.14.0" />
    <PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />

I verified the Package Installation by checking the Packages folder in my solution directory. This folder contained subdirectories for each installed package, including NUnit and its adapters.

However when I try to execute the tests through a cmd (because I want to execute the test project through a pipeline and send the result to sonarcloud)

"C:Program FilesMicrosoft Visual Studio2022ProfessionalCommon7IDEExtensionsTestPlatformvstest.console.exe" /Logger:"trx;LogFileName=Test_Results.trx" "DDEFDDEF.TestsbinDebugnet461DDEF.Tests.dll"


dotnet test "DDEFDDEF.TestsbinDebugnet461DDEF.Tests.dll" --logger "trx;LogFileName=Test_Results.trx"

These commands generate a sonarcloud compatible trx file but with an error like this,

<?xml version="1.0" encoding="utf-8"?>
<TestRun id="4f4f533d-751a-4578-a73d-345d2932bb25" name="bob@bob0 2024-07-11 22:19:00" runUser="bob" xmlns="">
  <Times creation="2024-07-11T22:19:00.5007333+05:30" queuing="2024-07-11T22:19:00.5007337+05:30" start="2024-07-11T22:18:59.4303982+05:30" finish="2024-07-11T22:19:00.5013180+05:30" />
  <TestSettings name="default" id="d981d813-2556-4130-bc0c-2fccf0d764df">
    <Deployment runDeploymentRoot="bob_bob0_2024-07-11_22_19_00" />
    <TestList name="Results Not in a List" id="8c84fa94-04c1-424b-9868-57a2d4851a1d" />
    <TestList name="All Loaded Results" id="19431567-8539-422a-85d7-44ee4e166bda" />
  <ResultSummary outcome="Completed">
    <Counters total="0" executed="0" passed="0" 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" />
      <RunInfo computerName="bob0" outcome="Warning" timestamp="2024-07-11T22:19:00.3700990+05:30">
        <Text>No test is available in D:Sub./DDEF/DDEF.Tests/obj/Debug/net461/DDEF.Tests.dll. **Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.**</Text>

But when I used nunit3-console,

"D:NUnit.Console-3.17.0binnet35nunit3-console.exe" "DDEFDDEF.TestsbinDebugnet461DDEF.Tests.dll" --result="TestResults/DDEF_Test_Results.trx;format=nunit3"

This generated an execution report like this. But this report is not compatible with sonarcloud.

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<test-run id="0" runstate="Runnable" testcasecount="9" result="Passed" total="9" passed="9" failed="0" warnings="0" inconclusive="0" skipped="0" asserts="13" engine-version="" clr-version="4.0.30319.42000" start-time="2024-07-11 15:44:05Z" end-time="2024-07-11 15:44:07Z" duration="1.938986">

What am I doing wrong here?
How can I generate a trx file which is compatible with sonarcloud?
Any guidance on this is highly appreciated.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website