Reputation: 5203
I'm using SemanticComparison in my unit tests (NUnit) and often getting errors like this:
Expected Likeness of T But was T
I tracked errors like these down before, as this is due to some subproperty not being equal to the expected value that I defined in my unit test. But the error message just has this very general form. And I also see nothing in the stack trace. But I would imagine the library contains someway to automatically show the property that is different. Manual tracking them all takes me quite some time.
For completeness, my code is something like below. However I hope this question is read by someone familiar with SemanticComparison (it's a library/NuGet package for helping with unit tests made by Mark Seemann aka Ploeh. It's a side project of AutoFixture.).
_sut = new someService(apiKey);
var expectedResultaat = new someService {
Prop1 = 1,
Prop2 = 2,
}
var expected = expectedResultaat.AsSource().OfLikeness<ServiceResult>()
.Without(i => i.Prop1)
// Assert.
Assert.AreEqual(expected, actual);
Upvotes: 1
Views: 368
Reputation: 233150
Use
expected.ShouldEqual(actual);
instead of
Assert.AreEqual(expected, actual);
Upvotes: 2