Skip to content
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

Fails to discover unit tests #6976

Closed
msundbakken opened this issue Oct 14, 2016 · 4 comments
Closed

Fails to discover unit tests #6976

msundbakken opened this issue Oct 14, 2016 · 4 comments

Comments

@msundbakken
Copy link

Steps to reproduce

I'm trying to test a .NET 4.5.2 assembly from a .NET Core assembly/application for unit test purposes. I want to use ASP.NET's in-memory web server.

I've tried with both MSTest and xUnit but it's actually dotnet.exe that fails.

My project.json:

{
"version": "1.0.0-*",

"testRunner": "xunit",

"buildOptions": { "platform": "x64" },

"dependencies": {
"NETStandard.Library": "1.6.0",
"xunit": "2.2.0-beta3-build3402",
"xunit.runner.console": "2.2.0-beta3-build3402"
},

"frameworks": {
"netstandard1.6": {
"imports": "dnxcore50"
},
"net452": {
"dependencies": {
"MyProject": {
"target": "project"
}
}
},
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
}
}
},
"runtimes": {
"win10-x64": {}
}
}

Expected behavior

Discover my unit tests.

Actual behavior

Cannot find unit tests.

Trimmed my project path.

------ Discover test started ------
========== Discover test finished: 0 found (0:00:01.7073428) ==========
------ Discover test started ------
Discovering tests in project.json ["C:\Program Files\dotnet\dotnet.exe" test "project.json" --output "[......]\bin\Debug\netstandard1.6\win10-x64" --port 56859 --parentProcessId 50760 --no-build]
Unable to start C:\Program Files\dotnet\dotnet.exe
dotnet-test Error: 0 : [ReportingChannel]: Waiting for message failed System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.IO.Stream.ReadByte()
at System.IO.BinaryReader.ReadByte()
at System.IO.BinaryReader.Read7BitEncodedInt()
at System.IO.BinaryReader.ReadString()
at Microsoft.DotNet.Tools.Test.ReportingChannel.ReadMessages()

Unhandled Exception: System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.IO.Stream.ReadByte()
at System.IO.BinaryReader.ReadByte()
at System.IO.BinaryReader.Read7BitEncodedInt()
at System.IO.BinaryReader.ReadString()
at Microsoft.DotNet.Tools.Test.ReportingChannel.ReadMessages()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
dotnet-test Error: 0 : [ReportingChannel]: Error sending System.IO.IOException: Unable to write data to the transport connection: Cannot access a disposed object.
Object name: 'System.Net.Sockets.Socket'.. ---> System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.Sockets.Socket'.
at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, SocketError& errorCode)
at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.IO.BinaryWriter.Write7BitEncodedInt(Int32 value)
at System.IO.BinaryWriter.Write(String value)
at Microsoft.DotNet.Tools.Test.ReportingChannel.Send(Message message)
dotnet-test Error: 0 : System.IO.IOException: Unable to write data to the transport connection: Cannot access a disposed object.
Object name: 'System.Net.Sockets.Socket'.. ---> System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.Sockets.Socket'.
at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, SocketError& errorCode)
at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.IO.BinaryWriter.Write7BitEncodedInt(Int32 value)
at System.IO.BinaryWriter.Write(String value)
at Microsoft.DotNet.Tools.Test.ReportingChannel.Send(Message message)
at Microsoft.DotNet.Tools.Test.ReportingChannel.SendError(String error)
at Microsoft.DotNet.Tools.Test.ReportingChannel.SendError(Exception ex)
at Microsoft.DotNet.Tools.Test.DesignTimeRunner.HandleDesignTimeMessages(ProjectContext projectContext, DotnetTestParams dotnetTestParams)
at Microsoft.DotNet.Tools.Test.DesignTimeRunner.DoRunTests(ProjectContext projectContext, DotnetTestParams dotnetTestParams)
at Microsoft.DotNet.Tools.Test.BaseDotnetTestRunner.RunTests(ProjectContext projectContext, DotnetTestParams dotnetTestParams, BuildWorkspace workspace)
at Microsoft.DotNet.Tools.Test.TestCommand.DoRun(String[] args)
========== Discover test finished: 0 found (0:00:01.4474715) ==========

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-preview2-003131)

Product Information:
Version: 1.0.0-preview2-003131
Commit SHA-1 hash: 635cf40

Runtime Environment:
OS Name: Windows
OS Version: 10.0.14931
OS Platform: Windows
RID: win10-x64

@pthalacker
Copy link

I am experiencing exactly the same problem. My project.json is nearly identical except my only framework is netcoreapp1.0. The exception information is identical

@pthalacker
Copy link

I installed the dotnet-test-xunit package and Test Explorer is again finding and running my tests

@khayes
Copy link

khayes commented Oct 29, 2016

I'm also having the same problem, even for solutions where it previously worked. I recently re-imaged my machine and re-opened previous solutions I worked on to find that Visual Studio can't discover the tests due to the above error, though dotnet test from the command line does work fine.

My frameworks section looks as follows:

    "frameworks": {
        "net451": {
            "dependencies": {
                "Microsoft.NETCore.Platforms": "1.0.1"
            },
            "buildOptions": {
                "define": ["NET4_5"]
            }
        },
        "netcoreapp1.0": {
            "imports": "dnxcore50",
            "dependencies": {
                "Microsoft.NETCore.App": {
                    "type": "platform",
                    "version": "1.0.0"
                }
            }
        }
    }

Removing net451 as a target framework allows Visual Studio to discover the tests again.
I am using xUnit and the in-built Visual Studio test runner. Having followed https://xunit.github.io/docs/getting-started-dotnet-core.html step by step.

@TheRealPiotrP
Copy link
Contributor

@pthalacker @msundbakken it sounds like your issue was a missing dotnet-test-xunit reference. Glad that got solved!

@khayes it looks like your issue is a problem in the VS tooling and not the CLI. Can you open an issue on https://github.com/aspnet/tooling to help the team get to the bottom of this?

9swampy referenced this issue in 9swampy/Telnet Feb 15, 2017
…ub.com/dotnet/cli/issues/4417 Solution to add dotnet-test-xunit not possible as doesn't support NetStandard1.6.
@msftgits msftgits transferred this issue from dotnet/cli Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants