I have a test where I do not need to run the SetUp method (attributed with [SetUp]) before running the test. I need the SetUp method t
Here is the code that I suggest for accomplishing what you want.
public const string SKIP_SETUP = "SkipSetup";
Now add the following method:
private static bool CheckForSkipSetup()
{
var categories = TestContext.CurrentContext.Test?.Properties["Category"];
bool skipSetup = categories != null && categories.Contains("SkipSetup");
return skipSetup;
}
Now check the condition as follows:
[SetUp]
public async Task Dosomething()
{
if (!CheckForSkipSetup())
{
}
}
Use these in test cases as follows:
[Test]
[Category(SKIP_SETUP)]
public async Task Mywork()
{
}