Questions tagged [xunit]

xUnit is the collection name for unit-testing compliant frameworks following a specific architecture. Implementation differs from language to language but the framework should consist of a Test Runner, Test Case, Test Fixture (Context), Test Suite, Test Execution, Test Result Formatter and Assertions

xUnit has been implemented for most languages, examples include JUnit, NUnit, CUnit, CppUnit, xUnit.net and more. The first implementation was made for Smalltalk by Kent Beck and is called SUnit.

3147 questions
1
vote
1 answer

How to configure VS Appcenter to run xUnit tests for Xamarin/Droid

Based on example for NUnit, available in Appcenter github repository I got following post-build script: #!/usr/bin/env bash echo "Found Unit test projects" find $APPCENTER_SOURCE_DIRECTORY -regex '*.Tests*\.csproj' -exec echo {} \; echo echo "Run…
Andris
  • 1,262
  • 1
  • 15
  • 24
1
vote
0 answers

VS 2019 Community version 16.4.0 gives error for Test Explorer

VS19 community version is giving error.Checking Test Output Pane gives this error: at Microsoft.VisualStudio.TestWindow.Controller.OperationBroker.<>c__DisplayClass17_0.<b__0>d.MoveNext() --- End of stack trace from previous…
Jazzy
  • 11
  • 3
1
vote
2 answers

NXunit Test Explorer isn't showing tests on VS Code (Test Explorer UI)

I'm making a custom HTML Helper inside a .NET Core 2.0 project, also there's a XUnit Test Project who belongs to the same solution, I have managed to test in console and everything runs fine, but I have to navigate on folders by console going in and…
elG
  • 539
  • 1
  • 6
  • 20
1
vote
1 answer

Injecting a fake concrete class via FakeItEasy and AutoFixture

I've got a class I want to test where a concrete class (MyClient) is being injected. private readonly MyClient _client; public Sync(MyClient client) { _client = client; } For testing we're using xUnit, AutoFixture and FakeItEasy. This all…
Jan_V
  • 4,244
  • 1
  • 40
  • 64
1
vote
1 answer

XUnit tests only works in command line not VSCode GUI

I have a project that was created in VisualStudio and after migrated to Visual Studio Code. Now I have the following problem, when executing Debug Test or Run Test in VSCode: I got the following error: Test run will use DLL(s) built for framework…
Ronaldo Lanhellas
  • 2,975
  • 5
  • 46
  • 92
1
vote
1 answer

I need xUnit test case of this. Microsoft.Azure.Cosmos Container

I have use Cosmosdb Container its abstract class. I need xUnit test case with mock using Moq library public class SmsTemplateRepository : ISmsTemplateRepository { private Container _container; public SmsTemplateRepository(CosmosClient…
user12444478
1
vote
2 answers

Exception message in xunit includes parameter so my test fails

I am trying to check that an exception that I throw gives the correct error message. I have a method in a class that withdraws (substracts) from a value. If the value is less than 0, I throw an exception. if (amount < 0) { throw new…
Anton Ödman
  • 451
  • 3
  • 7
  • 17
1
vote
3 answers

Unit Testing in ASP.NET MVC

Just embarking on using a test framework for writing unit tests and also the TDD approach. Not having any prior experience felt it would be good to go for XUnit although NUnit was the best alternative. Trying to transpose the MS Unit testing methods…
Euston
  • 81
  • 2
  • 10
1
vote
1 answer

Mocking MongoDb Methods such as Find,FindAsync Method in Xunit

I am trying to mock mongodb's findasync,find methods in Xunit & .net core. When i tried to mock the InsertOne, mockcollection.setup(x=>x.InsertOneAsync(_newitem,null,It.IsAny()).Returns(task.CompletedTask); but the find is…
sam0606
  • 21
  • 1
  • 3
1
vote
1 answer

XUnit custom data attribute executes for every test

I have a custom data attribute in xUnit. public class MyTest : DataAttribute { private readonly int _x; private readonly int _y; public MyTest(int x, int y) { _x = x; _y = y; } public override…
LP13
  • 30,567
  • 53
  • 217
  • 400
1
vote
1 answer

Moq test on inherited class always returns null

I am having a problem with setting up Unit Tests for a controller that implements a repository pattern. I want to check the return value of the controller. When setting up my Mock's for the Repository, the inherited IRepository methods always return…
dbarth
  • 228
  • 3
  • 6
1
vote
1 answer

How can I create unit tests for a Xamarin project in Visual Studio?

I have Xamarin Android project created in Visual Studio. I would like to create unit test project for my mobile app. I tired xUnit Test Project but I have problem with linking both projects: Linking xUnit with Android app I tried also Unit Test App…
Mateusz Piwowarski
  • 559
  • 1
  • 6
  • 15
1
vote
1 answer

xUnit: Passing object containing reference to static fields as theory

I'm going to test function returning array of von Neumann neighbours of cell in 2D Array. Cells contains data about simulation. To conduct test I'm setting new Cell[,] and populate with Cell instances. The test should check if neighbours returned by…
chalwa
  • 82
  • 9
1
vote
1 answer

How to use Intersection (AND) trait filter with xunit.runner.console

I've categorized my test with two principal traits (Severity and Domain) and I need to execute them filtering by the intersection of both of them. With dotnet test it's possible to do it without problem, but I need to do it with the…
1
vote
0 answers

xUnit parallelism and environment variables

I have a bunch of xUnit tests to test various behaviours of a class whose behaviour is determined by environment variables. This isn't the problem. The problem is that environment variables are per-process, not per-thread, and the tests interfere…
Dylan Nicholson
  • 1,301
  • 9
  • 23
1 2 3
99
100