I want to move from MSTest to XUnit and installed the following VS extentions
I can write facts and run my tests successfully, but for some reason Assert is unrecognised
I don't have any XUnit extensions installed. Instead I installed these packages from NuGet into my Test library.
Giving:
And a packages.config of:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="xunit" version="2.1.0" targetFramework="net451" />
<package id="xunit.abstractions" version="2.0.0" targetFramework="net451" />
<package id="xunit.assert" version="2.1.0" targetFramework="net451" />
<package id="xunit.core" version="2.1.0" targetFramework="net451" />
<package id="xunit.extensibility.core" version="2.1.0" targetFramework="net451" />
<package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net451" />
<package id="xunit.runner.visualstudio" version="2.1.0" targetFramework="net451" />
</packages>
Then I created a class:
using Xunit;
public class FunFacts
{
[Fact]
public void PassingTest()
{
Assert.Equal(4, Add(2, 2));
}
[Fact]
public void FailingTest()
{
Assert.Equal(5, Add(2, 2));
}
int Add(int x, int y)
{
return x + y;
}
}
The tests then passed and failed as expected.
Steps taken from the XUnit - Getting Started Page.
I followed all the advice that was given in the comments and answers provided and made sure that the following was done
I noticed that the nuget packages was not on the latest version available, so I updated to the latest available versions which resolved the issue.
using Xunit;in the file?