Click here to Skip to main content
15,894,825 members
Articles / Web Development / ASP.NET / ASP.NET Core

Testing Validation Attributes with xUnit

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
21 May 2020CPOL2 min read 11.7K   2  
An explanation of how to test validation attributes with xUnit
To test the validation of data models for REST API Controllers, just creating an instance of the controller class and calling the intended method is not an option. It simply does not test the validation, it skips the validation. We need a real REST Call but we need it from our xUnit test, not a manual call when starting the application manually. Two packages (Refit and IntegrationFixture) can help us with that and this article explains how.

Views

Daily Counts

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Netherlands Netherlands
I am a self-employed software engineer working on .NET Core. I love TDD.

Comments and Discussions