xunit

XUnit Assertion for checking equality of objects

社会主义新天地 提交于 2019-12-09 05:02:39
问题 I am using XUnit framework to test my C# code. Is there any assert method available in this framework which does the object comparison? My intention is to check for equality of each of the object's public and private member variables. I tried those alternatives but seldom it works: 1) bool IsEqual = (Obj1 == Obj2) 2) Assert.Same(Obj1, Obj2) which I couldnt understand what happens internally 回答1: You need to have a custom comparer to achieve this, when you compare objects otherwise they are

Converting Go testing output to XUnit

隐身守侯 提交于 2019-12-08 21:08:47
问题 How can I have the output of Go's testing library output in XUnit format for integration with Jenkins? There are no command line options to output to XML or to XUnit format with go test . 回答1: There's a nice little plugin to convert: https://github.com/tebeka/go2xunit To install it: go get github.com/tebeka/go2xunit To use it: # Run your tests like normal, but pipe the verbose output to the converter go test -v | $GOPATH/bin/go2xunit > test_output.xml If you have $GOPATH/bin in your normal

Xunit The following constructor parameters did not have matching fixture data

本秂侑毒 提交于 2019-12-08 17:39:56
问题 I keep getting this error while using xunit for .NET 1.0 framework net46. The following constructor parameters did not have matching fixture data I have seen this post: Collection fixture won't inject and followed the instructions regarding collection fixture closely as described here: http://xunit.github.io/docs/shared-context.html#collection-fixture Nothing seems to work. Any suggestions to what might cause this? 回答1: In my case it turned out to be a matter of doing it right according to

Resharper xUnit tests not working after installing .NET Core 2.0

妖精的绣舞 提交于 2019-12-08 17:30:27
问题 Right after installing .NET Core SDK 2.0, all tests a solution that targets the previous version of .NET Core fail to be discovered by Resharper. Also, when I add them manually to the session and attempt to run them, I get an "Inconclusive: Test not run": Also, there's these exceptions along with the previous message: If I uninstall .NET Core SDK 2.0, everything works as expected. No issues at all. Tried both x86 and x64 versions, same results. All projects in the solution target .NET Core 1

Running code on assembly load in xUnit

本秂侑毒 提交于 2019-12-08 17:26:14
问题 I am using the Effort library as a mock database, and it has some initialization code that has to run on assembly load. I have tried adding this initialization code in a static constructor that is referenced from every test via a base class constructor but this did not meet the requirements of the library. An answer to a similar question here mentions an AssemblyInitialize attribute, but this is not applicable to xUnit - xUnit has no way of running code on assembly load. I also asked on the

The following constructor parameters did not have matching fixture data

本秂侑毒 提交于 2019-12-08 16:22:58
问题 I'm trying to test my controllers using xUnit but getting the following error during execution of Customer Controller: "The following constructor parameters did not have matching fixture data: CustomerController customerController" Test Class public class UnitTest1 { CustomerController _customerController; public UnitTest1(CustomerController customerController) { _customerController = customerController; } [Fact] public void PostTestSuccessful() { Guid guid = Guid.NewGuid(); CustomerViewModel

xUnit.net v2 not discovering .NET Core Tests in Visual Studio 2015

亡梦爱人 提交于 2019-12-08 15:57:30
问题 I am really frustrated with this issue. I have already tried changing the version numbers but no tests are showing in the test explorer. In the test output window I can see this output Starting Microsoft.Framework.TestHost [C:\Users\sul\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta4\bin\dnx.exe --appbase "path to test project" Microsoft.Framework.ApplicationHost --port 63938 Microsoft.Framework.TestHost --port 63954 list ] Unable to start Microsoft.Framework.TestHost ========== Discover test

What's an xUnit runsettings equivalent?

南笙酒味 提交于 2019-12-08 15:09:40
问题 We have several environments that had their own run settings when we used MSTest. Since Microsoft is abandoning MSTest we are switching to xUnit. Whether it's through a runsettings or a command line property, I need a way to specify TestRunParameters in my xUnit test. Does xUnit have a native way to do that like MSTest or do I need to come up with my own solution? 来源: https://stackoverflow.com/questions/38458979/whats-an-xunit-runsettings-equivalent

How to duplicate MSTest attachment functionality with XUnit?

人盡茶涼 提交于 2019-12-08 12:37:00
问题 This Collect screenshots and video azure-devops page describes how to attach files to test reports generated while running tests with MSTest. The page links to a github repo where a class is provided which claims to publish files for a test run, but the code appears to be more concerned with handling values in a temporary CSV file. Given that this is for the benefit of those using XUnit (or any non-MSTest-based test runner) there are some problems... The first is how to identify a test

Exception upon using FsCheck

孤街醉人 提交于 2019-12-08 07:40:53
问题 Upon running with xUnit the simplest test from FsCheck open FsCheck [<Property>] let revRevIsOrig (xs:list<int>) = List.rev(List.rev xs) = xs I receive the exception ---- System.InvalidCastException : Unable to cast object of type 'FsList@303[System.Int32]' to type 'FsCheck.Arbitrary`1[Microsoft.FSharp.Collections.FSharpList`1[System.Int32]]'. I tried to catch the exception and debug, but occurs before Would anyone have any clue on how to solve this ? Way to reproduce: make a new project