This repository has been archived by the owner on Dec 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
No report if OneTimeSetUp is failed #1
Comments
Hi @undron Thanks for this case. I'll check whether NUnit allows accessing SetUp methods using ITestAction |
@undron I wrote the following method to bypass it: public static class AllureHelper {
public static void SetUp(Action setUpAction) {
try {
setUpAction.Invoke();
} catch (Exception e) {
var allure = AllureLifecycle.Instance;
var test = TestContext.CurrentContext.Test;
var testResult = new TestResult {
uuid = test.ID,
name = test.MethodName,
fullName = test.FullName,
descriptionHtml = $ "Tests wasn't able to run - an exception occured in setUp methods of <b>{test.ClassName}</b> - {setUpAction.Method.Name} method",
labels = new List < Label > {
Label.Suite(test.ClassName),
Label.Thread(),
Label.Host(),
Label.TestClass(test.ClassName),
Label.TestMethod(test.MethodName),
Label.Severity(SeverityLevel.blocker)
}
};
allure.StartTestCase(testResult);
allure.UpdateTestCase(x => x.statusDetails = new StatusDetails {
message = e.Message,
trace = e.StackTrace
});
allure.StopTestCase(x => x.status = Status.none);
allure.WriteTestCase(test.ID);
throw;
}
} It's not perfect - but maybe it can help you. [OneTimeSetUp] //or [SetUp]
public void ThisWillFail()
{
AllureHelper.SetUp(() =>
{
var x = 0;
var y = 1 / x;
});
} |
Thank you, I know about nunit/nunit#652 and have no idea too how to bypass it. <test-suite type="TestFixture" id="0-1011" name="Class3" fullname="NUnit.Allure.Class3" classname="NUnit.Allure.Class3" runstate="Runnable" testcasecount="1" result="Failed" label="Error" site="SetUp" start-time="2017-11-20 13:31:59Z" end-time="2017-11-20 13:31:59Z" duration="0.003892" total="1" passed="0" failed="1" warnings="0" inconclusive="0" skipped="0" asserts="0">
<failure>
<message><![CDATA[System.DivideByZeroException : Attempted to divide by zero.]]></message>
<stack-trace><![CDATA[ at NUnit.Allure.Class3.OneTimeFailedSetup()]]></stack-trace>
</failure>
<test-case id="0-1012" name="Xxx4" fullname="NUnit.Allure.Class3.Xxx4" methodname="Xxx4" classname="NUnit.Allure.Class3" runstate="Runnable" seed="1822106949" result="Failed" label="Error" site="Parent" start-time="0001-01-01 00:00:00Z" end-time="0001-01-01 00:00:00Z" duration="0.000000" asserts="0">
<failure>
<message><![CDATA[OneTimeSetUp: System.DivideByZeroException : Attempted to divide by zero.]]></message>
</failure>
</test-case>
</test-suite> |
Yep, unfortunately, I didn't find the solution for current NUnit. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Great job!
But is any ideas, how to bypass error in OneTimeSetUp method for fixture?
This test will not be included in report, because ITestAction attribute will be applied after OneTimeSetUp
The text was updated successfully, but these errors were encountered: