Has anyone been able to get the combination of AutoFixure, FakeDb and NUnit3 to work?
I am unable to retrieve an item I have added to the database (using example from FakeDb AutoFixture wiki page); the test does not pass:
<package id="Sitecore.FakeDb" version="1.7.4" targetFramework="net472" />
<package id="Sitecore.FakeDb.AutoFixture" version="1.7.4" targetFramework="net472" />
<package id="AutoFixture" version="3.51.0" targetFramework="net472" />
<package id="AutoFixture.NUnit3" version="3.51.0" targetFramework="net472" />
<package id="NUnit" version="3.11.0" targetFramework="net472" />
[Test]
[AutoDbData]
public void AddContentDbItem(Db db, DbItem item)
{
db.Add(item);
var newItem = db.GetItem(item.ID);
newItem.Should().NotBe(null);
}
However, if I bypass the NUnit attribute integration with AutoFixure, the test passes (but this loses a lot of the benefits I wanted when using AutoFixture):
[Test]
public void AddContentDbItem()
{
var fixture = new Fixture()
.Customize(new AutoDbCustomization())
.Customize(new AutoContentItemCustomization());
var item = fixture.Create<DbItem>();
var db = fixture.Create<Db>();
db.Add(item);
var newItem = db.GetItem(item.ID);
newItem.Should().NotBe(null);
}
This suggest to me that the issue is with the interaction between Sitecore.FakeDb and Autofixture.NUnit3 (rather then NUnit itself).
Also, if I change the testing framework to XUnit, the test will pass:
<package id="AutoFixture.Xunit2" version="3.51.0" targetFramework="net472" />
<package id="xunit.core" version="2.4.1" targetFramework="net472" />
[Theory]
[AutoDbData]
public void AddContentDbItem(Db db, DbItem item)
{
db.Add(item);
var newItem = db.GetItem(item.ID);
newItem.Should().NotBe(null);
}
Has anyone been able to get the combination of AutoFixure, FakeDb and NUnit3 to work? NUnit has been the preferred testing framework in my company for years and there is reluctance to change just to solve this issue.