Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests should use TheoryData<> #11041

Open
JeremyKuhne opened this issue Mar 12, 2024 · 9 comments · May be fixed by #11171
Open

Tests should use TheoryData<> #11041

JeremyKuhne opened this issue Mar 12, 2024 · 9 comments · May be fixed by #11171
Labels
help wanted Good issue for external contributors
Milestone

Comments

@JeremyKuhne
Copy link
Member

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 JeremyKuhne added the help wanted Good issue for external contributors label Mar 12, 2024
@JeremyKuhne JeremyKuhne added this to the Future milestone Mar 12, 2024
@dotnet-policy-service dotnet-policy-service bot modified the milestones: Future, Help wanted Mar 12, 2024
@paul1956
Copy link
Contributor

paul1956 commented Mar 12, 2024 via email

@elachlan
Copy link
Contributor

@woefulpines
Copy link

I was wondering if I could work on this issue.

@elachlan
Copy link
Contributor

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

@paul1956
Copy link
Contributor

paul1956 commented Mar 16, 2024 via email

@woefulpines
Copy link

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.

@elachlan
Copy link
Contributor

elachlan commented Apr 2, 2024

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

@woefulpines
Copy link

woefulpines commented Apr 5, 2024

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.

@RussKie
Copy link
Member

RussKie commented Apr 5, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Good issue for external contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants