Answer the question
In order to leave comments, you need to log in
What is the best way to set the Inconclusive status if the component does not exist?
Hello,
There is a small problem in that you need to test data from a piece of iron.
The piece of iron is not always connected to the computer and not everyone has it and in fact not everyone needs it.
Desire - so that if it is not there, the tests do not fall, but give Inconclusive .
Actually googled only such a solution with a base class.
In the base class, a connection test and cleanup after that. If the test fails, nothing is tested in the inherited one and shows Inconclusive. The base class should not be visible in the Test Explorer.
Are there better options?
[TestFixture]
public class TestClassInheritanceBase
{
private bool _isConnected;
[SetUp]
public void BaseSetUp()
{
_isConnected = false;
Debug.WriteLine("base. SetUp");
}
[SetUp]
public void BaseTearDown()
{
Debug.WriteLine("Base. SetUp");
}
public void TestIsConnected()
{
if (!_isConnected)
{
Assert.Inconclusive("Device missing.");
}
}
}
[TestFixture]
public class TestClassInheritance: TestClassInheritanceBase
{
[SetUp]
public void SetUp()
{
Debug.WriteLine("SetUp");
}
[SetUp]
public void TearDown()
{
Debug.WriteLine("SetUp");
}
[Test]
public void TestMethod()
{
TestIsConnected();
var answer = 42;
Assert.That(answer, Is.EqualTo(42), "Some useful error message");
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question