Ich habe einige Bibliotheken auf .NET Core, die net45
und netstandard1.6
Ziel und ich möchte sie Unit-Test. Ich tat dotnet new -t xunittest
und das erstellte ein neues Testprojekt, das auf netcoreapp1.0
abzielt, damit es nur den .NET-Kerncode testet.Unit Testing Code für mehrere Frameworks auf einmal mit .NET Core und xUnit
Ich habe versucht, es auch zu kompilieren, um auch net45
zu tarnen, aber dann habe ich eine Reihe von Fehlern beim Test entdeckt. Meine Fragen sind
Gibt es eine Möglichkeit, den Code zu testen, der auf beide (vielleicht später) Frameworks mit einem einzigen Testprojekt abzielt, oder soll ich ein Testprojekt für jedes einzelne Ziel erstellen?
bearbeiten: hier sind meine project.json
und die Nachrichten, die ich bin immer:
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable"
},
"dependencies": {
"xunit": "2.1.0"
},
"testRunner": "xunit",
"frameworks": {
"net45": {
"frameworkAssemblies": {
"System.Runtime": "4.0.0.0"
}
},
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"System.Runtime.Serialization.Primitives": "4.1.1",
"dotnet-test-xunit": "2.2.0-preview2-build1029"
},
"imports": [
"dotnet5.4",
"portable-net451+win8"
]
}
}
}
das sind die Fehler, die ich bekommen, wenn das Projekt kompiliert wird:
dotnet-test Error: 0 : [ReportingChannel]: Waiting for message failed System.IO.IOException: Unable to read data om the transport connection: An established connection was aborted by the software in your host machine. ---> stem.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()
>dotnet-test Error: 0 : Unhandled Exception: System.IO.IOException: Unable to read data from the transport nnection: An established connection was aborted by the software in your host machine. ---> stem.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 ate)
[ReportingChannel]: Error sending System.IO.IOException: Unable to write data to the transport connection: Cannot cess 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, cketError& 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 sposed 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, cketError& 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, tnetTestParams dotnetTestParams)
at Microsoft.DotNet.Tools.Test.DesignTimeRunner.DoRunTests(ProjectContext projectContext, DotnetTestParams tnetTestParams)
at Microsoft.DotNet.Tools.Test.BaseDotnetTestRunner.RunTests(ProjectContext projectContext, DotnetTestParams tnetTestParams, BuildWorkspace workspace)
at Microsoft.DotNet.Tools.Test.TestCommand.DoRun(String[] args)
und finalisiert mit diesem Linie
========== Discover test finished: 0 found (0:00:03.0417342) ==========
obwohl ich weiß, dass ich einen Test (zumindest bis jetzt) habe.
aber wenn ich die net 45
Referenzen alle Arbeiten wie Charme entfernen, hier ist meine Arbeit project.json
:
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable"
},
"dependencies": {
"System.Runtime.Serialization.Primitives": "4.1.1",
"xunit": "2.1.0",
"dotnet-test-xunit": "2.2.0-preview2-build1029"
},
"testRunner": "xunit",
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
},
"imports": [
"dotnet5.4",
"portable-net451+win8"
]
}
}
}
Was sind die Fehler, die Sie bekommen haben? Und könnten Sie genauer beschreiben, was Sie getan haben, damit wir die Fehler reproduzieren können? – svick
@svick Ich habe gerade meine Frage bearbeitet und die Fehler und 'project.json' Daten hinzugefügt. Ich hoffe, das hilft – Luiso