public void DataCleanUp(ScenarioContext scenarioContext, DataSetUpHelper helper) { var objectsToBeDeleted = TestHelper.GetListOfObjectsToBeRemoved(scenarioContext); if (objectsToBeDeleted.Count > 0) { foreach (var objectToRemove in objectsToBeDeleted) { helper.Delete(objectToRemove); } } }
public void CloseDriver() { try { var status = CurrentContext.Result.Outcome.Status; var stacktrace = CurrentContext.Result.StackTrace; var errorMessage = CurrentContext.Result.Message; var screenShot = Capture($"{CurrentContext.Test.ClassName}_{CurrentContext.Test.ID}"); Status logStatus; string message = $"Test ended with "; switch (status) { case TestStatus.Failed: logStatus = Status.Fail; message += $"{logStatus} - {errorMessage}"; childTest.Log(logStatus, $"Test ended with {logStatus} - {errorMessage}"); break; case TestStatus.Skipped: logStatus = Status.Skip; message += $"{logStatus}"; break; default: logStatus = Status.Pass; message += $"{logStatus} "; break; } childTest.Log(logStatus, message, screenShot); // remove data DataSetUpHelper helper = new DataSetUpHelper(ValidCredentials.Username, ValidCredentials.Password); foreach (var obj in _setUpContext.GetObejcts()) { helper.Delete(obj); } } catch (Exception) { throw; } finally { DriverManager.CloseDriver(); } }