xunit.net

Help troubleshooting System.BadImageFormatException:

狂风中的少年 提交于 2020-01-04 14:31:27
问题 While debugging through a .NET 3.5 SP1 project which is contacting a local web service, I'm receiving the exception System.BadImageFormatException: "Bad Class Token" Of course there aren't much more details about what's causing the exception. I can tell that the method where this occurs, which is in the same class as it's caller, the debugger fails to reach. This exception occurs on the call of the method that contacts the web service. I do have other methods communicating with the web

Testing F# async workflows with xUnit.net's Task support

怎甘沉沦 提交于 2020-01-03 11:04:16
问题 I'm writing F# code and tests in xUnit 1.9. For normal sync stuff, I simply return unit and all is well; but now, I'm migrating the sync innards to be async workflows. In other words, my simple AAA is getting explicit Async usage pushed out into it as I refactor the system: let [<Fact>] ``Can consume using NEventStore InMemory`` () = let store = NesGateway.createInMemory () let finalDirection = playCircuit store |> Async.RunSynchronously // <----- YUCK test <@ CounterClockWise =

Testing F# async workflows with xUnit.net's Task support

試著忘記壹切 提交于 2020-01-03 11:01:53
问题 I'm writing F# code and tests in xUnit 1.9. For normal sync stuff, I simply return unit and all is well; but now, I'm migrating the sync innards to be async workflows. In other words, my simple AAA is getting explicit Async usage pushed out into it as I refactor the system: let [<Fact>] ``Can consume using NEventStore InMemory`` () = let store = NesGateway.createInMemory () let finalDirection = playCircuit store |> Async.RunSynchronously // <----- YUCK test <@ CounterClockWise =

IsType<T> and IsType(object, object) throwing IsTypeException

倖福魔咒の 提交于 2020-01-03 08:31:36
问题 I am attempting to assert that an object being returned by a method call is of the type List<MyClass> , so using xUnit I have tried the following: var expected = typeof(List<MyClass>); var actual = typeof(method()); Assert.IsType<List<MyClass>>(actual); Assert.IsType(expected, actial); Both of the above throw the IsTypeException however if I perform: var areSameType = expected == actual areSameType is true . So is there something going on deeper down that I am not accounting for? Docs: http:/

xUnit.net Test Stripper [to remove test code embedded in binaries prior to deployment/shipping]

强颜欢笑 提交于 2020-01-03 05:19:12
问题 Is there a Test Stripper (as defined in xUnit Test Patterns) available that supports removing classes containing methods tagged as [Fact]s etc. plus the dependency on xunit.dll from binaries [as part of a build process] ? Further details of the full requirements and context are at this xUnit CodePlex post. Failing that (something that removes the tests and the reference to the DLL), does anyone have a utility/proven clean approach to removing the xunit.dll dependecy without too much monkeying

Testing UWP app with xUnit on VS2015

a 夏天 提交于 2020-01-02 07:16:08
问题 I have managed to create an xUnit project on VS2015 to unit-test UWP apps. There is a background to this question here on stackoverflow which gives some context to this question. I can compile and run the test, however when I reference a project to be tested, the following error comes up. ------ Run test started ------ Updating the layout... Checking whether required frameworks are installed... Registering the application to run from layout... Deployment complete (1857ms). Full package name:

dotCover and xUnit not gathering coverage statistics in some environments

那年仲夏 提交于 2020-01-01 18:50:42
问题 We're using dotCover 2.7 and xUnit.net 1.9.2. On my machine (Windows 7) and a co-worker's machine (Windows 8) we can run dotCover from the command line against one of our unit test assemblies that uses xUnit.net and get correct coverage reporting. On our build machine (Windows Server 2008 R2 Standard) when we run the same thing the only code coverage that dotCover reports is the unit test assembly itself. We're running xUnit.net using the MSBuild task. Here's the relevant pieces from the

No xunit tests discovered by vstest.console.exe

有些话、适合烂在心里 提交于 2019-12-31 12:54:18
问题 I'm putting together a new stack of unit tests to be run together as a CI job. I'm using vstest.console.exe instead of mstest.exe mainly for its ability to run tests from several frameworks, but right now the focus is a few xUnit dlls. The jobs are run as part of a Jenkins pipeline. I have tested everything successfully on a couple of dev boxes, but annoyingly test discovery is not working on any of the CI build boxes so far. This is after the addition of the 0.99.8 xUnit test adapter vsix

How to verify order of execution in XUnit Moq?

北城余情 提交于 2019-12-24 10:55:37
问题 I have the following class: public class Foo { public int Prop1 { get; set; } public string Prop2 { get; set; } public Stream TestStream; public WriteToTestStream() { ... } } WriteToTestStream writes to the TestStream . I want to write a Unit Test to make sure that Prop1 and Prop2 are being set before writing to the TestStream The properties should not be accessed once something is written to the TestStream . How can I define a Mock for WriteToTestStream in this case? How can I manipulate

How to exclude null value when using FsCheck Property attribute?

a 夏天 提交于 2019-12-24 08:58:46
问题 I need to write a simple method that receives a parameter (e.g. a string ) and does smth. Usually I'd end up with two tests. The first one would be a guard clause. The second would validate the expected behavior (for simplicity, the method shouldn't fail): [Fact] public void DoSmth_WithNull_Throws() { var sut = new Sut(); Assert.Throws<ArgumentNullException>(() => sut.DoSmth(null)); } [Fact] public void DoSmth_WithValidString_DoesNotThrow() { var s = "123"; var sut = new Sut(); sut.DoSmth(s);