Created
March 2, 2023 14:49
-
-
Save manoj-choudhari-git/7638283bc29bbb0b85c77761052cdfab to your computer and use it in GitHub Desktop.
.NET Test Projects - Ignore and Skip the tests in MSTest and xUnit Frameworks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ======================================================================= | |
// MSTest Test Example To Ignore A Test | |
// ======================================================================= | |
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
using Prime.Services; | |
namespace Prime.UnitTests.Services | |
{ | |
[TestClass] | |
public class PrimeService_IsPrimeShould | |
{ | |
private readonly PrimeService _primeService; | |
public PrimeService_IsPrimeShould() | |
{ | |
_primeService = new PrimeService(); | |
} | |
[TestMethod] | |
[Ignore] | |
public void IsPrime_InputIs1_ReturnFalse() | |
{ | |
bool result = _primeService.IsPrime(1); | |
Assert.IsFalse(result, "1 should not be prime"); | |
} | |
} | |
} | |
// ======================================================================= | |
// xUnit Test Example To Skip A Test | |
// ======================================================================= | |
using Xunit; | |
using Prime.Services; | |
namespace Prime.UnitTests.Services | |
{ | |
public class PrimeService_IsPrimeShould | |
{ | |
[Fact(Skip="Some Reason")] | |
public void IsPrime_InputIs1_ReturnFalse() | |
{ | |
var primeService = new PrimeService(); | |
bool result = primeService.IsPrime(1); | |
Assert.False(result, "1 should not be prime"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment