How do I skip specific tests in xUnit based on current platform
XUnit v2.0 is now available. Skippable tests are supported by it directly. Use: [Fact (Skip = “specific reason”)]
XUnit v2.0 is now available. Skippable tests are supported by it directly. Use: [Fact (Skip = “specific reason”)]
2021-Apr-01 update I recommend using FluentAssertions. It has a vast IntelliSense-friendly assertion library for many use cases including collections collection.Should().Equal(1, 2, 5, 8); collection.Should().NotEqual(8, 2, 3, 5); collection.Should().BeEquivalentTo(8, 2, 1, 5); Original answer xUnit.Net recognizes collections so you just need to do Assert.Equal(expected, actual); // Order is important You can see other available collection assertions … Read more
The Assert.Throws expression will catch the exception and assert the type. You are however calling the method under test outside of the assert expression and thus failing the test case. [Fact] public void ProfileRepository_GetSettingsForUserIDWithInvalidArguments_ThrowsArgumentException() { //arrange ProfileRepository profiles = new ProfileRepository(); // act & assert Assert.Throws<ArgumentException>(() => profiles.GetSettingsForUserID(“”)); } If bent on following AAA you … Read more
You are mixing unit test with integration test. TestServer is for integration test and if you want to reuse Startup class to avoid register dependencies again, you should use HttpClient and make HTTP call to controller and action that use IDepartmentAppService. If you want do unit test, you need to setup DI and register all … Read more
I’m going to go a step further than Yoshi’s comment. The Performed invocations message tells you the method was called but not with the parameters that you were verifying. My guess based on the messages is that there’s something wrong with the first parameter. You would need to post the test for me to be … Read more
To my surprise, clearing temp files located in the %TEMP% directory resolved the issue for me. Note: This path is generally at C:\Users\(yourusername)\AppData\Local\Temp As @Warren-P included, you can navigate to the temp folder by putting in %temp% in Start Menu, or launch “File Explorer” and enter %temp% in the address bar.
I did a similar thing a few months ago, and it turned out this simple format was enough for Hudson to accept it as a test protocol: <testsuite tests=”3″> <testcase classname=”foo1″ name=”ASuccessfulTest”/> <testcase classname=”foo2″ name=”AnotherSuccessfulTest”/> <testcase classname=”foo3″ name=”AFailingTest”> <failure type=”NotEnoughFoo”> details about failure </failure> </testcase> </testsuite> This question has answers with more details: Spec. for … Read more
There are many xxxxData attributes in XUnit. Check out for example the MemberData attribute. You can implement a property that returns IEnumerable<object[]>. Each object[] that this method generates will be then “unpacked” as a parameters for a single call to your [Theory] method. See i.e. these examples from here Here are some examples, just for … Read more