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

Update to latest Xunit and Moq, fix test bugs, stop suppressing analyzers #10077

Merged
merged 16 commits into from
Jul 22, 2024

Conversation

joelverhagen
Copy link
Member

@joelverhagen joelverhagen commented Jul 22, 2024

Currently we have a bunch of test bugs that are hidden by these problems:

  • We are on old Xunit. Newer Xunit has improved source analyzers to show problems
    • Example problem: methods missing [Fact] or [Theory] meaning test cases weren't running at all
    • Example problem: unawaited Task or async void resulting assert does not get observed
    • Example problem: unused parameter in [Theory] meaning only one variant of the test was really running
  • test.ps1 had broken file paths in several cases... meaning the UT projects weren't event running

Summary of changes:

  • Move to xunit 2.9.0, xunit.runner.visualstudio 2.8.2 (latest) and clean up dependencies on Xunit
  • Clean up minor build warnings
  • Delete .editorconfig. All it does is suppress everything meaning these warnings/errors were hidden!
  • Fix tests broken and unobserved due to test.ps1 path issue
  • Improve test.ps1 to catch when tests don't produce result XML
  • Use Assert.Single, Assert.Empty, Assert.Contains, etc per the Xunit analyzer
  • Suppress xUnit1015 in two cases where we have a child class provide test data to a parent class [MemberData] (weird, but works)
  • Suppress xUnit1032 in AccountsControllerFacts since we provide child classes for this generic class meaning the tests do actually run
  • Improved the read only mode checks in EntitiesContext. It was possible to work around the check via SaveChanges variants
  • Skip MvcBuildViews=true when building debug. This makes build.ps1 faster locally, does not affect CI/release.
  • Move to Moq 4.20.70, set up HTTP response code due to changes in Moq

Progress on https://github.com/NuGet/Engineering/issues/5427.

@joelverhagen joelverhagen requested a review from a team as a code owner July 22, 2024 15:37
@joelverhagen joelverhagen changed the title Update to latest Xunit, fix test bugs, stop suppressing analyzers Update to latest Xunit and Moq, fix test bugs, stop suppressing analyzers Jul 22, 2024
@agr
Copy link
Contributor

agr commented Jul 22, 2024

@joelverhagen
Copy link
Member Author

NuGet/Engineering#5427 - related?

Yes, thank you! I will take ownership and do this too:

image

@joelverhagen joelverhagen merged commit 54bbdb7 into dev Jul 22, 2024
2 checks passed
@joelverhagen joelverhagen deleted the jver-fix-uts branch July 22, 2024 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants