This is a migrated thread and some comments may be shown as answers.

NUnitTestMethod not calling RUN

1 Answer 62 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ken
Top achievements
Rank 1
Ken asked on 28 Apr 2015, 03:01 AM

I'm writing a decorator (to implement a Retry attributes for NUnit tests). Everything runs fine when executing with Telerik JustTest -- except:

* "Not Executed" is reported

* Stepping thru in debug, "Run" is never called

Using NUnit 2.6. I have read that Resharper has issues in this same area and there are workarounds. We run Nunit for deployment builds, and I would like to be able to run the tests in VS.

    public class RetriedTestMethod : NUnit.Core.Test
    {
        private readonly int requiredPassCount;
        private readonly int tryCount;
        private readonly NUnit.Core.Test backingTest;

        public RetriedTestMethod(NUnitTestMethod test, int tryCount, int requiredPassCount)
            : base((TestName)test.TestName.Clone())
        { //executes in debug
            backingTest = test;
            this.tryCount = tryCount;
            this.requiredPassCount = requiredPassCount;
        }
          private static bool TestFailed(TestResult result)
        {
            return result.ResultState == ResultState.Error || result.ResultState == ResultState.Failure;
        }
        public override TestResult Run(EventListener listener, ITestFilter filter)
        { //Never called
            var successCount = 0;
            TestResult failureResult = null;
            for (var i = 0; i < this.tryCount; i++)
            {
                var result = backingTest.Run(listener, filter);
                if (!TestFailed(result))
                {
                    if (i == 0)
                    {
                        return result;
                    }
                    if (++successCount >= this.requiredPassCount)
                    {
                        return result;
                    }
                }
                else
                {
                    failureResult = result;
                }
            }
            return failureResult;
        }

I attached the set of files with unit tests.

1 Answer, 1 is accepted

Sort by
0
Boyan Boev
Telerik team
answered on 30 Apr 2015, 02:06 PM
Hi Ken,

Thank you for contacting us.

This forum is related to Telerik Testing Framwork. 

Do you use it for building your tests? I cannot fully understand from your post.

If not I will change this thread to JustCode.

Looking forward to hearing from you.

Regards,
Boyan Boev
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
Ken
Top achievements
Rank 1
Answers by
Boyan Boev
Telerik team
Share this question
or