Skip to content

Warning when Is.Not.Null.Or.Empty used #189

@Dreamescaper

Description

@Dreamescaper

Operators are a bit confusing in NUnit. Personally I don't fully understand how they work.

I've seen multiple times that constraint Is.Not.Null.Or.Empty is used to validate that string is not empty, which is wrong - it should be either Is.Not.Null.And.Not.Empty, or Is.Not.Null & Is.Not.Empty, or !Is.Null.Or.Empty.
But it might be missed because Not operator precedence is not obvious (one of the reasons I prefer using &/| operators instead of .And/.Or).

Since Is.Not.Null.Or.Empty constraint makes no sense (empty string or collection is always not null), I suggest always marking it as warning.

Any ideas for other commonly misused constraints?

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions