ananthoju / mb-unit

Automatically exported from code.google.com/p/mb-unit
0 stars 0 forks source link

TestOutcome is always 'Passed' in teardown method when assigned from StaticTestFactory #928

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Execute the below test

public class FactoryTest
{
    [StaticTestFactory]
    public static IEnumerable<Test> CreateStaticTests()
    {
        var testcase = new TestCase("simpletest" , () =>
        {
            Assert.Fail("staticfactory created test failed.");
        });

        testcase.TearDown = FactoryAssignedTearDownMethod;

        yield return testcase;
    }

    public static void FactoryAssignedTearDownMethod()
    {
        //outcome value is always 'Passed', even when test fails
        TestLog.WriteLine("Test Outcome Status from factory assigned method: " + TestContext.CurrentContext.Outcome.Status);
    }
}

What is the expected output? What do you see instead?
I am trying to read the test outcome from the Teardown method so that I can log 
it to an external system for reporting purposes.
However, TestContext.CurrentContext.Outcome.Status always returns 'Passed' from 
FactoryAssignedTearDownMethod.

What version of the product are you using? On what operating system?
v3.4.0.0.  Windows 7 x86.

Please provide any additional information below.
When using a regular method with the [TearDown] attribute, Outcome.Status value 
is correctly returned.

Original issue reported on code.google.com by faiz.ha...@gmail.com on 10 Sep 2013 at 11:26