Skip to content

Instantly share code, notes, and snippets.

@manoj-choudhari-git
Created March 2, 2023 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manoj-choudhari-git/7638283bc29bbb0b85c77761052cdfab to your computer and use it in GitHub Desktop.
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
// =======================================================================
// 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