Devon Bessemer
Devon Bessemer

Reputation: 35347

Exclude namespaces from dotnet test

How can we exclude a specific namespace from dotnet test?

dotnet test --filter FullyQualifiedName~Namespace.Here works for including a namespace, but !~ is not recognized for excluding a namespace.

Upvotes: 4

Views: 14758

Answers (2)

Henrik Gering
Henrik Gering

Reputation: 1881

According to https://learn.microsoft.com/en-us/dotnet/core/testing/selective-unit-tests?pivots=mstest you need to escape the exclamation mark:

Using filters that include exclamation mark ! on *nix requires escaping since ! is reserved.

So i guess you need to do:

dotnet test --filter FullyQualifiedName\!~Namespace.Here

Upvotes: 5

FeRaaC
FeRaaC

Reputation: 486

Ok, so to elaborate on my half-assed comment: As of now the !~ operator is not supported (see here).

If you want to exclude a specific namespace completely from your tests I think your best bet would be to work with test categories. It is a suboptimal work around for what you want to do in the first place, as it may lead to every test in your namespace have an additional category which just states that it's in this namespace.

But unfortunately as of right now there is no way to filter by namespaces except inclusions.

Upvotes: 1

Related Questions