-
Notifications
You must be signed in to change notification settings - Fork 158
Assert.Fail
jnm2 edited this page Jun 14, 2017
·
5 revisions
The Assert.Fail method provides you with the ability to generate a failure based on tests that are not encapsulated by the other methods. It is also useful in developing your own project-specific assertions.
Assert.Fail();
Assert.Fail(string message, params object[] parms);
Here's an example of its use to create a private assertion that tests whether a string contains an expected value.
public void AssertStringContains(string expected, string actual)
{
AssertStringContains(expected, actual, string.Empty);
}
public void AssertStringContains(string expected, string actual, string message)
{
if (actual.IndexOf(expected) < 0)
Assert.Fail(message);
}
Copyright (c) 2018 The NUnit Project - Licensed under CC BY-NC-SA 4.0
-
NUnit
-
Release Notes
-
License
- Getting Started
- Writing Tests
- Running Tests
- Extending NUnit
- Technical Notes
-
Release Notes
- NUnit Xamarin Runners
- VS Test Adapter
- VS Test Generator
- NUnit Analyzers