NeotericSh
NeotericSh
CC#
Created by NeotericSh on 7/8/2024 in #help
Extending the Assert class in xunit
This is what I ended up with: namespace Tests.Extensions; public class Assert { public static void DoesNotThrow(Action action) { try { action(); } catch (Exception e) { throw new Exception($"Expected no exception, but got: {e.Message}"); } } }
11 replies
CC#
Created by NeotericSh on 7/8/2024 in #help
Extending the Assert class in xunit
After some more exploring, I was unable to create an extension on the Assert class. And it just boils down to that it is a class that just have static methods in it. Looked at the source for xunit and ended up writing a wrapper class instead in the same style. Maybe you guys already know this, but if I mark a method with [Fact] and then throw an exception it counts as a bad test case, and if nothings happens it counts as a good test case. Thought I would share that.
11 replies