Questions tagged [xunit.net]

xUnit.net is a unit testing tool for the .NET Framework. Written by the original inventor of NUnit, xUnit.net is the latest technology for unit testing C#, F#, VB.NET and other .NET languages. It works with ReSharper, CodeRush, and TestDriven.NET.

Written by the original inventor of NUnit v2, xUnit.net is the latest technology for unit testing C#, F#, VB.NET and other .NET languages. xUnit.net works with ReSharper, CodeRush, TestDriven.NET and Xamarin

See more at http://xunit.github.io/

1001 questions
24
votes
2 answers

Running unit tests in TFS/VSO Build vNext using xUnit adapter

I am trying to run our xUnit tests using the xUnit test adapter in Visual Studio Online's Build vNext platform. As stipulated in this article, we need to provide a custom test adapter path pointing to xunit.runner.visualstudio.testadapter.dll. But…
Dave New
  • 38,496
  • 59
  • 215
  • 394
23
votes
1 answer

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

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…
Meysam
  • 555
  • 1
  • 3
  • 16
23
votes
5 answers

Is there a way to unit test an async method?

I am using Xunit and NMock on .NET platform. I am testing a presentation model where a method is asynchronous. The method creates an async task and executes it so the method returns immediately and the state I need to check aren't ready yet. I can…
Jiho Han
  • 1,610
  • 1
  • 19
  • 41
22
votes
2 answers

xUnit Assert.All() async

I have this example test using xUnit: [Fact] public void SomeTest() { Assert.All(itemList, async item=> { var i = await Something(item); Assert.Equal(item,i); …
J2ghz
  • 632
  • 1
  • 7
  • 20
21
votes
4 answers

xUnit.net how can I specify a timeout how long a test should maximum need

I have integration tests set up with xUnit.net. Is there a way to configure how long an integration test should last maximum? I mean a threshold.
codefruit
  • 388
  • 1
  • 2
  • 7
21
votes
2 answers

How to handle exceptions thrown by Tasks in xUnit .net's Assert.Throws?

The following asynchronous xUnit.net test with a lambda marked with the async modifier fails by reporting that no exception was thrown: [Theory, AutoWebData] public async Task SearchWithNullQueryThrows( SearchService sut, …
Nikos Baxevanis
  • 10,868
  • 2
  • 46
  • 80
21
votes
3 answers

In xUnit.net, is it possible to run tests in order?

I know you generally should not depend on order for your unit tests, but in xunit is it possible to make your tests run in a certain order?
Lance Fisher
  • 25,684
  • 22
  • 96
  • 122
21
votes
2 answers

xUnit and Moq do not support async - await keywords

I am trying to discover how to apply the async and await keywords to my xUnit tests. I am using xUnit 1.9 and Async CTP 1.3. Here is my test case I have an interface which specifies one asynchronous method call public interface IDoStuffAsync { …
Keith Bloom
  • 2,391
  • 3
  • 18
  • 30
20
votes
9 answers

Collection fixture won't inject

I'm using xUnit 2.0 collection fixtures to share a common database setup/teardown between a number of different test classes. The fixture also provides some helper properties, so I'm injecting it into each test class. I recreated the example in the…
Nate Barbettini
  • 51,256
  • 26
  • 134
  • 147
20
votes
4 answers

How can I run xUnit Unit Tests with VS2015 Preview?

I added the "xUnit.net runner for Visual Studio" v0.99.8 via Extensions Manager, but when I open the Test Explorer window, it does not seem to pick up any of my unit tests. Also, the Resharper 9 EAP does which is the only version of Resharper that…
Omer Raviv
  • 11,409
  • 5
  • 43
  • 82
19
votes
2 answers

xUnit test using data coming from external file

In these days I'm trying to understand how xUnit tests work and, in particular, I discovered that there are 3 ways to pass data as parameters in order to test class methods (InlineData, ClassData and MemberData). But here Is my issue: is there any…
Ruber
  • 342
  • 1
  • 2
  • 12
19
votes
0 answers

XUnit InlineData with Objects?

Recently we have been trying Unit Testing in a new project, now that we want to pass a Object to our test method with [InlineData], so we can utilize the same test method multiple times with multiple different data inputs. [ClassData] and…
Sprite
  • 359
  • 1
  • 3
  • 11
19
votes
2 answers

Get VS Test Explorer to show only test name not full type name

My VS test explorer shows tests including the full type name, like so: CompanyName.ProjectName.Web.Tests.SutDoesWhatItShould Instead of just: SutDoesWhatItShould This is highly unreadable/annoying. How do I fix this? I'm using the xunit runner…
Aage
  • 5,932
  • 2
  • 32
  • 57
18
votes
6 answers

Howto resolve .net test hangs on "Starting test execution, please wait..."

I am trying to execute dotnet test from the command line on our Jenkins build server, but it just hangs on: Starting test execution, please wait... It works fine when running this command locally If I switch to using dotnet xunit it fails with the…
David Masters
  • 8,069
  • 2
  • 44
  • 75
18
votes
2 answers

How to unit test ActionFilterAttribute

I'm looking to test an ActionFilterAttribute in a .NET Core 2.0 API project and wondering the best way to go about it. Note, I'm not trying to test this through a controller action, merely test the ActionFilterAttribute itself. How might I go about…