© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
1 reply
QuickZ

TestInitialize runs after constructor causing nullable warnings

I am using the [TestInitialize] attribute on a method to run code only once per complete testrun, and in there initialise your Mocks. This will lead to that you will get the kinda new nullable warnings since this is not run in the constructor. And if you have fields that are not instantiated in the constructor then the intellisense will pick it up as you are exiting the constructor with unasigned fields just having null (this is however the design and accepted). Is there a recommended way of avoiding these warnings?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Dealing/resolving nullable warnings
C#CC# / help
3y ago
❔ JSON serialization nullable warnings (best approach?)
C#CC# / help
3y ago
✅ Best practices regarding non-nullable property warnings?
C#CC# / help
2y ago
Unit Test, TestInitialize alternative in xUnit
C#CC# / help
12mo ago