jeudi 10 octobre 2019

C#: Retry/Rerun Tests either at [TestClass] or at [TestMethod] Level

I have a suite of Selenium based end to end tests in C#. Currently I am using MSTest so I will use its terminology but I am open to switching to NUnit or XUnit if they offer better solutions.

Each test scenario is implemented as a [TestClass] that is made up of several steps implemented as [TestMethod]s.

The environment in which the tests are run is dependent on many SOAP and REST web services that are external to the team. Unfortunately many of these resources are unstable and the process of stabilizing them is ongoing and slow.

As a result, I need to compensate in my test suite by using a retry mechanism. In some cases, when a step fails, I would like to retry that step for up to 3 times. In other cases, when a step fails I am forced to retry the entire scenario from the beginning.

My question is: Is there an existing retry mechanism that I can use, that is flexible enough to sometimes be applied to a [TestMethod] and other times to an entire [TestScenario]?

PS - I am aware of NUnit's [Retry] attribute and of MsTestEx' [Retry] attribute. Both are applicable to the [Test] / [TestMethod] respectively. I guess I am looking for something similar, only for the [TestFixture] / [Test].

Aucun commentaire:

Enregistrer un commentaire