FsCheck
FsCheck copied to clipboard
Support for NUnit TestContext.AddFormatter
Would it be possible to support NUnits ValueFormatters configured with TestContext.AddFormatter für FsCheck.Nunit tests?
Could you give an example of what you’d like to see working, but doesn’t currently?
Also to manage expectations: on FsCheck.NUnit I am happy to take PRs but unlikely to write any new features myself.
Thank you for the heads up. Let me explain my problem: ` sealed class Custom_Type { public int ID {get;set;} public string Name {get;set;}
public override string ToString() => "Insufficient Information to identify Data";
}
public void Setup() { TestContext.AddFormatter(x => $"CustomType: (Id: {((Custom_Type)x).Id}, Name: {((Custom_Type)x).Name})" }
[Property( ... )]
public Property Sample_with_custom_type(Custom_Type arg) {
Assert.Fail();
}
With the current Versions I see the following message:
Falsifiable, after 1 test (0 shrinks) (StdGen (649505996,296942915)):
Original:
Insufficient Information to identify Data
`
Instead I would prefer to see the following message:
Falsifiable, after 1 test (0 shrinks) (StdGen (649505996,296942915)): Original: CustomType: (Id: {((Custom_Type)x).Id}, Name: {((Custom_Type)x).Name})
If there is a way to achieve the second error message in this case with some configuration for FsCheck.Core I think I can integrate an adapter to the NUnit Custom formatters into FsCheck.NUnit.
Yes I think this should be doable - again caveat my knowledge about NUnit is limited - but it seems like that should be a matter of routing FsCheck's output through NUnit's output system somehow: https://github.com/fscheck/FsCheck/blob/master/src/FsCheck.NUnit/FsCheckPropertyAttribute.fs#L25
We do a similar thing for FsCheck.Xunit, which has a ITestOutputHelper
we write to.