Closed vikassd2012 closed 1 year ago
I cannot reproduce the problem with your ZIP file.
The two commands I ran after unzipping your repro project were:
dotnet build build.proj
dotnet test build.proj /p:CollectCoverage=true /p:CoverletOutput=./TestResults/ /p:CoverletOutputFormat=cobertura /p:CopyLocalLockFileAssemblies=true --configuration Release --logger 'trx;LogFileName=ci_tests.trx' --logger 'console;verbosity=detailed' -v d --no-build
This worked as expected on Ubuntu 18.04:
It also worked with the mcr.microsoft.com/dotnet/core/sdk:3.1
Docker image:
Thanks @bradwilson for looking into this. This is strange why we are seeing this issue. I will compare your test environment and try to see if there any differences.
Closing this for age. My best recommendation would be to open this with the .NET team to understand why your hand-crafted .proj file does not work when a normal .csproj file does.
Hi there,
Spoke earlier with Xunit team on slack including Brad Wilson about this issue. He suggested to file this issue with repro project.
We have a jenkin pipeline that runs our dotnet core tests : ENVIRONMENT: Docker container based of mcr.microsoft.com/dotnet/core/sdk:3.1 (3.1.301 dotnet --version)
Here is summary of issue:
dotnet test Services/MyService/build.proj /p:CollectCoverage=true /p:CoverletOutput=./TestResults/ /p:CoverletOutputFormat=cobertura /p:CopyLocalLockFileAssemblies=true --configuration Release --logger trx;LogFileName=ci_tests.trx --logger console;verbosity=detailed -v d --no-build
We have at least 10 other microservices that use this same way to execute tests and it works consistently. However we added a new service in our solution and this new service is giving below message while we try to run the tests:
However instead of this .proj file, if we execute the test directly like this:
dotnet test tests/UnitTests/UnitTestProject/UnitTestProject.csproj
It works.dotnet test tests/UnitTests/UnitTestProject/UnitTestProject.csproj
Test works as earlier.b. Then run the dotnet test again via the other command:
dotnet test build.proj /p:CollectCoverage=true /p:CoverletOutput=./TestResults/ /p:CoverletOutputFormat=cobertura /p:CopyLocalLockFileAssemblies=true --configuration Release --logger 'trx;LogFileName=ci_tests.trx' --logger 'console;verbosity=detailed' -v d --no-build
But since I ran the step a, I noticed step b also works now. Its able to find the test and run the test.
Attaching a sample application with which we were able to reproduce the issue. For Xunit Team.zip
STEPS TO REPRODUCE
dotnet test build.proj /p:CollectCoverage=true /p:CoverletOutput=./TestResults/ /p:CoverletOutputFormat=cobertura /p:CopyLocalLockFileAssemblies=true --configuration Release --logger 'trx;LogFileName=ci_tests.trx' --logger 'console;verbosity=detailed' -v d --no-build
EXPECTED RESULTS:
Starting test execution, please wait...
A total of 1 test files matched the specified pattern. /Users/vyadav/Desktop/For Xunit Team/tests/UnitTests/UnitTestProject/bin/Release/netcoreapp3.1/UnitTestProject.dll [xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.0 (64-bit .NET Core 3.1.5) [xUnit.net 00:00:00.36] Discovering: UnitTestProject [xUnit.net 00:00:00.40] Discovered: UnitTestProject [xUnit.net 00:00:00.41] Starting: UnitTestProject [xUnit.net 00:00:00.49] Finished: UnitTestProject √ UnitTestProject.UnitTest1.Test1 [2ms] Results File: /Users/vyadav/Desktop/For Xunit Team/tests/UnitTests/UnitTestProject/TestResults/ci_tests.trx
Test Run Successful. Total tests: 1 Passed: 1 Total time: 1.1717 Seconds
Test run for /home/ec2-user/workspace/ipeline_els_jenkins-repro-simple/Services/ErrorLookupService/tests/UnitTests/UnitTestProject/bin/Release/netcoreapp3.1/UnitTestProject.dll(.NETCoreApp,Version=v3.1) Microsoft (R) Test Execution Command Line Tool Version 16.6.0 Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern. /home/ec2-user/workspace/ipeline_els_jenkins-repro-simple/Services/ErrorLookupService/tests/UnitTests/UnitTestProject/bin/Release/netcoreapp3.1/UnitTestProject.dll No test is available in /home/ec2-user/workspace/ipeline_els_jenkins-repro-simple/Services/ErrorLookupService/tests/UnitTests/UnitTestProject/bin/Release/netcoreapp3.1/UnitTestProject.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again. Results File: /home/ec2-user/workspace/ipeline_els_jenkins-repro-simple/Services/ErrorLookupService/tests/UnitTests/UnitTestProject/TestResults/ci_tests.trx
Additionally, path to test adapters can be specified using /TestAdapterPath command. Example /TestAdapterPath:.