Blake Rivell
Blake Rivell

Reputation: 13875

Disable/Prevent XUnit Warnings on build in .NET Core Test Project

I have a project with several large test cases in it and the project takes about 2-3 minutes to build. I am suspicious that it has to do with this new warnings feature... for example:

warning xUnit2003: Do not use Assert.Equal()
warning xUnit2004: Do not use Assert.Equal() to check for boolean conditions.

It is doing this for thousands of lines...

It would be great if there was a way to disable this feature. Not sure if it has to do with the visual studio runner or xunit itself.

Upvotes: 11

Views: 3464

Answers (2)

Roman Starkov
Roman Starkov

Reputation: 61432

Like any other warnings, xUnit warnings can also be disabled in .editorconfig which can then be standardised and reused across multiple projects:

dotnet_diagnostic.xUnit2013.severity = none

Upvotes: 2

Julian
Julian

Reputation: 36740

You could disable the warnings as follows:

  • for a file

    #pragma warning disable xUnit2003, xUnit2004
    

    optionally restore them:

    #pragma warning restore xUnit2003, xUnit2004
    

Or in your project properties:

enter image description here

Upvotes: 9

Related Questions