You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there already an analyzer that schould trigger when the following incorrect use happens?
This caused some isssues in my test library and I only found out after commenting out about 50 tests. So an analyzer would be great for that kind of scenario.
using System;using NSubstitute;using Xunit;namespace Tests;publicinterfaceIMyInterface{intMyMethod(stringmyParameter);}publicclassTestClass{[Fact]publicvoidIStItem_GetNext_ShouldThrow(){// Arrangevarsubstitute= Substitute.For<IMyInterface>();// Act/Assert
Assert.Throws<NotImplementedException>(()=> substitute.MyMethod(Arg.Any<string>()));// <-- INcorrect | should trigger
Assert.Throws<NotImplementedException>(()=> substitute.MyMethod(string.Empty));// <-- correct | should NOT trigger}}
The text was updated successfully, but these errors were encountered:
FroggieFrog
changed the title
Analayzer for misuse of Arg.Any<T> in xunits Asert.Throws<T>?
Analyzer for misuse of Arg.Any<T> in xunits Asert.Throws<T>?
Aug 24, 2023
Is there already an analyzer that schould trigger when the following incorrect use happens?
No, we dont have analyzer for these cases. We actually wanted to have one and attempted to write it but after testing on actual codebases we ended up with much simplified version which only check usages on non-virtual members. Here are relevant issue and pr with all necessary discussions why we ended up with rather basic analyzer for arg misuse #35 #120
Is there already an analyzer that schould trigger when the following incorrect use happens?
This caused some isssues in my test library and I only found out after commenting out about 50 tests. So an analyzer would be great for that kind of scenario.
The text was updated successfully, but these errors were encountered: