shani klein
shani klein

Reputation: 344

How to enable Nunit tests to run only on Linux OS (and don't run on Windows)?

I'm using Nunit for testing My Program (The tests run automatically when we doing build to the program).

The program runs on both Windows and Linux operation systems, and I have some tests which supposed to run only on Linux Os. Is there some way to make sure those tests will run only on Linux and not on Windows OS?

I know That in JUnit for exmaple there is possibility to add the title @EnabledOnOs(LINUX) , but I could not find something similar to Nunit.

Thank you very much.

Upvotes: 4

Views: 1078

Answers (1)

Charlie
Charlie

Reputation: 13736

Short answer: [Platform("Linux")]

NUnit will generate a reason but if you want a more detailed one, you can specify it.

[Platform("Linux", Reason="Only runs on Linux because... ")]

You may use this on methods or on an entire fixture class.

Upvotes: 7

Related Questions