SimplyVBUnit
SimplyVBUnit copied to clipboard
Assert.AreNotEqual not reporting actual value when test failed
When the test "Assert.AreNotEqual 1, 1" is attempted the error message contains the text Expected: not 1 But was : Empty
This behaviour is also seen if tests Assert.AreNotEqualFloats or Assert.AreNotEqualStrings are used.
I've traced this back to EqualConstraint.Matches. mActual is only populated when mComparer.Equals(mExpected, Actual) = False.
The fix is to always call "VariantCopyInd mActual, Actual" at the start of EqualConstraint.Matches.
Has anyone noticed this and if so do you have a different solution?
I didn't populate the mActual
field unless the test failed in an attempt to not create unnecessary copies of some kinds of variable types. Specifically strings and arrays. It's probably a completely unnecessary optimization, but it was written a long time ago and I was young :) I didn't even think about the NotConstraint
causing the failure and requiring a child constraint to write a message appropriate to the situation.
It seems the only solution is the one you described and will be applied for any upcoming releases.