Here is what I am trying to do:
public class MyTests
{
private IFixture _fixture;
public MyTests()
{
_fixture = new Fixture();
_fixture.Customize(x => x.With(y => y.UserId, 1));
}
[Theory, AutoData]
…
How can I access the IApplicationEnvironment from an xUnit 2 unit test?
There are several scenarios where I think I need this, including:
Read from a non-embedded configuration file built with the unit tests
Create and write files relating to the…
I've read http://xunit.github.io/docs/capturing-output.html and it seems to apply to making my test output specific message during the test running but I would really like to be able to capture the log4net output that is already integrated into the…
TextFixture and Test
public class TestFixture : IDisposable
{
public TestFixture()
{
var options = new ChromeOptions();
options.AddExcludedArgument("enable-automation");
…
Xunit2 is not running some tests properly from within Visual Studio 2019.
I recently migrated from NUnit to Xunit2 (removing all references to it in my projects). I installed Xunit2 following the directions on the official page, along with the nuget…
I am trying to write some tests, I use xUnit.net, Moq, AutoFixture. I need to inject service to my test method:
[Theory, AutoData]
public void TestSmthCool(IService service)
{
}
The IService has 3 dependencies which I want to mock. But, If I run…
I am implementing Xunit with Autofac, I could make it work by below code:
using (var scoped = DbFixture.Container.Resolve())
{
var result = (scoped.GetAll()).ToList().Count();
Assert.Equal(2, result);
}
But I want to inject…
I have a project created using Asp.Net Core, but I have a problem with unit testing one part of my controller's action, I use xUnit.net(2.2.0-beta2-build3300) for testing and Moq(4.6.25-alpha) for mocking, and FluentAssertions(4.13.0) and…
When doing a clean / rebuild on my solution so the tests appear in the Test Explorer I get the following error:
'An Unexpected error detected. Check the Tests Output Pane for details.'
And none of the tests appear anymore.
When I check the tests…
I am using the latest version of XUnit and I followed these steps to get the Class Library (.NET Core) project started.
All other libraries throughout my entire solution are only using 4.6.1 so I changed the frameworks section in project.json to the…
When I add the example xUnit2 target to my FAKE build file, I'm getting this error:
error FS0001: This expression was expected to have type
string option
but here has type
string
Target Example from FAKE xunit2…
I have some large test suites so I broke them into inner/nested classes. That also makes the results in the VSCode test explorer more friendly.
But it doesn't work well when there's common fixture data that's defined in the outer class:
public class…
In my project we are upgrading to xUnit 2. As a result, we upgraded the console runner also which is used to run tests on build server.
We did not upgrade the exsting test projects to use xUnit 2. They are still referring to xUnit.1.9.2.
As per the…
The following is not asserting to true with XUnit (StartDate and EndDate are the only two public properties of DatePeriod):
var actual = new List()
{
new DatePeriod() { StartDate = new DateTime(2017, 1, 20), EndDate = new…