question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Test execution failure on Linux

See original GitHub issue

Description

I have a .net core project with some unit tests. The unit test framework fails on Linux.

Steps to reproduce

Given this project file:

<Project Sdk="Microsoft.NET.Sdk">
	<Import Project="..\company.globals.props" />
	<PropertyGroup>
		<TargetFramework>netcoreapp3.1</TargetFramework>
		<OutputPath>$(BuildDir)</OutputPath>
		<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
	</PropertyGroup>

	<ItemGroup>
		<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
		<PackageReference Include="MSTest.TestAdapter" Version="2.1.0" />
		<PackageReference Include="MSTest.TestFramework" Version="2.1.0" />
		<PackageReference Include="coverlet.collector" Version="1.2.0" />
	</ItemGroup>
</Project>

When run this on Red Hat Enterprise Linux 8.2, from the command line using .net core. I get a runtime exception and the test execution fails. Execute the following command from the command line: dotnet test ./foo.csproj -p:Configuration=Debug

Expected behavior

This runs absolutely fine on windows:

Test run for C:\Users\me\source\repos\foo\builds\bin\x64\Debug\netcoreapp3.1\foo.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.

Test Run Successful.
Total tests: 28
     Passed: 28
 Total time: 4.6982 Seconds

Actual behavior

Test run for /home/admin/code/foo/builds/bin/x64/Debug/netcoreapp3.1/foo.dll(.NETCoreApp,Version=v3.1)
Microsoft (R) Test Execution Command Line Tool Version 16.3.0-dev+55e7e45431c9c05656c999b902686e7402664573
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...

A total of 1 test files matched the specified pattern.  

An exception occurred while invoking executor 'executor://mstestadapter/v2': Protocol error

Test Run Failed.

Environment

On Linux I have:

root (/home/admin/code/foo) $ dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.1.105
 Commit:    99c9707ea8

Runtime Environment:
 OS Name:     rhel
 OS Version:  8
 OS Platform: Linux
 RID:         rhel.8-x64
 Base Path:   /usr/lib64/dotnet/sdk/3.1.105/

Host (useful for support):
  Version: 3.1.5
  Commit:  65cd789777

.NET Core SDKs installed:
  3.1.105 [/usr/lib64/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.1.5 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.5 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]
...

On Windows (v10) I have:

.NET Core SDK (reflecting any global.json):
 Version:   3.1.301
 Commit:    7feb845744

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18362
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.1.301\

Host (useful for support):
  Version: 3.1.5
  Commit:  65cd789777

.NET Core SDKs installed:
  2.1.4 [C:\Program Files\dotnet\sdk]
  2.1.202 [C:\Program Files\dotnet\sdk]
  2.1.400 [C:\Program Files\dotnet\sdk]
  2.1.602 [C:\Program Files\dotnet\sdk]
  2.1.700 [C:\Program Files\dotnet\sdk]
  3.1.201 [C:\Program Files\dotnet\sdk]
  3.1.301 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Operating system, Build version of vstest.console, Package version of MSTest framework and adapter

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
danmincucommented, Jul 13, 2022

In my case the fix was to run the tests into a Linux folder and to copy the *.trx file in the folder that was mounted on Windows avoiding the cross OS folder name creation problem. However, this commit should fix it https://github.com/microsoft/testfx/pull/1119/files I’ll be able to test it soon after I upgrade the testfx framework.

0reactions
Evangelinkcommented, Sep 6, 2022

Hey @danmincu. I don’t know if you had time to confirm things are good now? I’ll move forward and close this ticket. If you have a repro of something that still fails, please either ping here or create a new issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Diagnosing a Linux-only unit test failure
We use both AppVeyor and Travis in CI, and only Travis was failing. There were two failures – one testing the equality operators,...
Read more >
Test works on local Windows machine but fails on Linux ...
The test succeeds when run locally through Eclipse on my Windows desktop but it fails at com.me.be.HeaderTests.
Read more >
Debugging Failing Tests and Test Pipelines
end of your day. follow up on test failures. escallate issue. report the failure. failed pipeline run. no failed pipeline runs. no. yes....
Read more >
Automation test scripts are failing in linux
Hi Team, All test script are running properly in windows environment , but couple of testcase are failing in linux environment.
Read more >
Linux - getting error while executing tests in Ubuntu
When i am trying to run the test zip, getting execution failure and there are no logs created anywhere. Please suggest where i...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found