winforms icon indicating copy to clipboard operation
winforms copied to clipboard

Tests should use TheoryData<>

Open JeremyKuhne opened this issue 11 months ago • 2 comments

Theory tests should preferably use the TheoryData<> pattern where possible. We have several hundred hits for the analyzer for this currently (xUnit1042). The analyzer is disabled in the .editorconfig file and can be commented out to hunt these down.

Once addressed we can turn this back on.

JeremyKuhne avatar Mar 12 '24 19:03 JeremyKuhne

Could you provide example or right and wrong?Sent from my iPhoneI apologize for any typos Siri might have made.(503) 803-6077On Mar 12, 2024, at 9:48 AM, Jeremy Kuhne @.***> wrote: Theory tests should preferably use the TheoryData<> pattern where possible. We have several hundred hits for the analyzer for this currently (xUnit1042). The analyzer is disabled in the .editorconfig file and can be commented out to hunt these down. Once addressed we can turn this back on.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

paul1956 avatar Mar 12 '24 23:03 paul1956

@paul1956 this had a good example in it: https://hamidmosalla.com/2020/04/05/xunit-part-8-using-theorydata-instead-of-memberdata-and-classdata/

elachlan avatar Mar 13 '24 22:03 elachlan

I was wondering if I could work on this issue.

woefulpines avatar Mar 16 '24 05:03 woefulpines

@woefulpines yes please. There will be a lot of refactoring involved. So lots to do. Keep the PRs smaller for quicker reviews.

elachlan avatar Mar 16 '24 06:03 elachlan

I have not seen anything (examples) for using TheoryData to replace InlineData, is it possible? Sent from my iPhoneI apologize for any typos Siri might have made.(503) 803-6077On Mar 15, 2024, at 9:42 PM, Lachlan Ennis @.***> wrote: @woefulpines yes please. There will be a lot of refactoring involved. So lots to do. Keep the PRs smaller for quicker reviews.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

paul1956 avatar Mar 16 '24 07:03 paul1956

Sorry for the delay. I was a little confused with how this was going to be done in small PRs. I was able to get a theory working with data and it was passing XUnit1042 in .editorconfig. Other projects and parts fail, I was thinking of keeping the editor config changes local until given the green light. I can work ahead but I just wanted to see how best to proceed.

woefulpines avatar Apr 02 '24 22:04 woefulpines

Yes, the .editorconfig changes will be merged separately once all occurrences have been fixed.

elachlan avatar Apr 02 '24 22:04 elachlan

I had some issues for one of the test cases I was converting. I was using TheoryData, but I end up with an error: cs0050.

It seems that returning a TheoryData<...> causes an issue since the accessibility is different from the function I am returning from. I was wondering if you had seen something like this before. I couldn't find anything from my googling and the other theory data conversions don't suffer from this issue.

woefulpines avatar Apr 05 '24 01:04 woefulpines

It seems that returning a TheoryData<...> causes an issue since the accessibility is different from the function I am returning from. I was wondering if you had seen something like this before. I was couldn't find anything from my googling and the other theory data conversions don't suffer from this issue.

In such cases, you generally have no other option but to suppress one or the other analyzer. Pick one of the lesser evils.

RussKie avatar Apr 05 '24 01:04 RussKie