xunit.net

Await Tasks in Test Setup Code in xUnit.net?

梦想与她 提交于 2019-12-20 16:52:50
问题 The exact situation is I'm doing E2E tests with Protractor.NET (.NET port of AngularJS's Protractor E2E framework) and I would like to make some web requests (and the API -- System.Net.Http.HttpClient -- has all Async/ Task methods) to Arrange my test before I Act/Assert, only I need to do this same Arrange-ing for several tests. I'm using xUnit.net as my test runner they use an interface ( IUseFixture<T> ) for per-fixture setup code. It would be nice if there was a IAsyncUseFixture<T> that

Xunit create new instance of Test class for every new Test ( using WebDriver and C#)

僤鯓⒐⒋嵵緔 提交于 2019-12-19 06:17:36
问题 Is there any way to run multiple tests in same browser using Webdriver (Selenium) using Xunit, , at present xunit launches new browser for every new test , below is the sample code public class Class1 { private FirefoxDriver driver; public Class1() { driver = new FirefoxDriver(); } [Fact] public void Test() { driver.Navigate().GoToUrl("http://google.com"); driver.FindElementById("gbqfq").SendKeys("Testing"); } [Fact] public void Test2() { driver.Navigate().GoToUrl("http://google.com"); driver

xunit Assert.ThrowsAsync() does not work properly?

我是研究僧i 提交于 2019-12-18 18:34:19
问题 So I have a test like the following: [Fact] public void Test1() { Assert.ThrowsAsync<ArgumentNullException>(() => MethodThatThrows()); } private async Task MethodThatThrows() { await Task.Delay(100); throw new NotImplementedException(); } To my surprise, Test1 passes successfully. To make it fail I have to write like this: Assert.Throws<ArgumentNullException>(() => MethodThatThrows().Wait()); What is the purpose of ThrowsAsync(), if it does not work in the scenario above? 回答1: You're supposed

Verifying complete Mapping of an [unordered] Collection/Set of Items in a Unit Test

只愿长相守 提交于 2019-12-18 09:24:08
问题 I'm using xUnit.net, AutoFixture and SemanticComparison and want to verify the results of a mapping. On the individual item level, I'm well covered. Given The items share an identifying key I want to do a comparison on the value elements on both side I don't care about ordering (and don't want my Assertion to break under re-ordering) How do I verify that each and every input item maps to one and only one output item in a DAMP yet DRY manner using as much OOTB componentry as possible ?

xUnit v1 tests appear in xUnit GUI (xunit.gui.clr4.exe) but not VS 2012 Test Explorer

微笑、不失礼 提交于 2019-12-18 05:05:11
问题 I have an F# Class Library with the "xUnit.net" and "xUnit.net Runners" packages installed using NuGet. I have the following code: module XUnitTest open Xunit [<Fact>] let Test () = do Assert.True (1 = 2) () When I run the xUnit GUI (xunit.gui.clr4.exe, which NuGet adds to (projectdirectory)\packages\xunit.runners.1.9.1\tools), and load the assembly built by this project, the Test () method appears, and fails when I run it, as expected. However, I cannot get the test to appear in VS 2012's

xUnit v1 tests appear in xUnit GUI (xunit.gui.clr4.exe) but not VS 2012 Test Explorer

女生的网名这么多〃 提交于 2019-12-18 05:05:06
问题 I have an F# Class Library with the "xUnit.net" and "xUnit.net Runners" packages installed using NuGet. I have the following code: module XUnitTest open Xunit [<Fact>] let Test () = do Assert.True (1 = 2) () When I run the xUnit GUI (xunit.gui.clr4.exe, which NuGet adds to (projectdirectory)\packages\xunit.runners.1.9.1\tools), and load the assembly built by this project, the Test () method appears, and fails when I run it, as expected. However, I cannot get the test to appear in VS 2012's

How do I get Team Build to show test results and coverage for xUnit.net test suite?

旧时模样 提交于 2019-12-18 04:55:23
问题 Has anybody had any success getting Team Build to show xUnit.net test results and code coverage in the build report? The MSBuild runner is running the tests just fine and the results are in the log file, but the test results and code coverage results areas of the build report say "No test result" and "No coverage result" respectively. Is Team Build looking for a certain location / format for the test results to be exported by the xUnit.net runner? 回答1: TFS/TeamBuild definitely requires the

Run code once before and after ALL tests in xUnit.net

不想你离开。 提交于 2019-12-17 15:37:25
问题 TL;DR - I'm looking for xUnit's equivalent of MSTest's AssemblyInitialize (aka the ONE feature it has that I like). Specifically I'm looking for it because I have some Selenium smoke tests which I would like to be able to run with no other dependencies. I have a Fixture that will launch IisExpress for me and kill it on disposal. But doing this before every test hugely bloats runtime. I would like to trigger this code once at the start of testing, and dispose of it (shutting down the process)

Cannot run Xunit with Visual Studio 2013 Community

蓝咒 提交于 2019-12-14 03:53:44
问题 I'm trying to get XUnit to work with Visual Studio 2013 Community (Version 12.0.31101.00 Update 4). I've got NUnit to work so I thought it would be simple to get XUnit to work. The code is using Xunit; namespace Xunit { public class Class1 { [Fact] public void myFirstTest() { Assert.False(true); } } } I've used the NuGet Package manager to install the following. XUnit.net is version 1.9.2 XUnit.net: Runners is version 1.9.2 I've seen videos of people running XUnit with VS2012 but no one with

How to run xUnit test DLL in Commandline without building the project

拈花ヽ惹草 提交于 2019-12-13 12:25:11
问题 I have a project in .NET Core and have built tests using xUnit. Now I wanted to run the test in deployment process. What I have done so far: I used this command in commandline: dotnet test [project address] ... it is working but the problem is that this command get the .csproj file and not the dll . I installed and used xunit.runner.console but its not working with .NET Core projects. I used dotnet xunit command, this one also not helped while I cannot give it the dll it is also using the