SwensenSoftware / unquote

Write F# unit test assertions as quoted expressions, get step-by-step failure messages for free
http://www.swensensoftware.com/unquote
Apache License 2.0
285 stars 26 forks source link

NUnit 3: ArgumentNullException on failure #120

Closed slav closed 8 years ago

slav commented 8 years ago

If tests fail I always get the following error. Any idea why? VS2015 with F# 4.6 NUnit 3

System.Exception: forwarded ---> System.TypeInitializationException: The type initializer for '<StartupCode$Unquote>.$Swensen.Unquote.Assertions' threw an exception. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: method
   at System.Delegate.CreateDelegate(Type type, MethodInfo method, Boolean throwOnBindFailure)
   at System.Delegate.CreateDelegate(Type type, MethodInfo method)
   at <StartupCode$Unquote>.$Swensen.Unquote.Assertions..cctor()
slav commented 8 years ago

Found the issue. There's typo in Assertions.fs on line 102.

Should by yield Nunit ty instead of yield Xunit ty for NUnit assembly

stephen-swensen commented 8 years ago

@slav thanks for finding this issue and pinpointing the cause. I believe the issue was introduced in Unquote 3.1.0 which was released on 10/10/2015. I will work on a hotfix release ASAP. In the meantime, you should be able to use Unquote 3.0.0 to avoid the issue. Apologies for the inconvenience.

stephen-swensen commented 8 years ago

Interestingly enough, it appears that this typo bug only affects NUnit 3.x whereas NUnit 2.x works fine due to symmetry between xUnit and NUnit 2.x assertion APIs. I am certainly still keen on fully supporting NUnit 3.x however.

slav commented 8 years ago

Yep, weird. Probably the reason it went un-noticed. Any idea when you'll release 3.1.1?

stephen-swensen commented 8 years ago

With any luck I can get something out this weekend, but may be more like some time next week.

Digger further I've determined that NUnit 3 is binary incompatible with NUnit 2 so this issue would have surfaced independent of the typo because the assembly name is the same between v3 and v2. Specifically, NUnit 2 has a method like

Assert.True(bool condition, string message); 

Whereas NUnit 3 only has

Assert.True(bool condition, string message, params object[] parms);

I am going to file an issue with the NUnit folks recommending that they take their NUnit 2 backwards compatibility further with binary compatibility instead of just C# syntactic compatibility.

stephen-swensen commented 8 years ago

@slav FYI Unquote 3.1.1 was just released with the fix for this.