Build/Test Issues

NUnit ITestAction not executed in 2.4 (works in 1.48.5)

Started by topdownjohnny on 7,117 views

Hi,

I have an attribute I use on tests:

public class FunctionVerifierAttribute : Attribute, ITestAction
   {
      private readonly SimpleFunctionVerifier _verifier;
      public FunctionVerifierAttribute(params FunctionType[] roles)
      {
         _verifier = new SimpleFunctionVerifier();
         roles.ToList().ForEach(i => _verifier.FunctionTypes.Add(i));

      }

      public void BeforeTest(TestDetails testDetails)
      {
         var fixture = testDetails.Fixture as IHasUserState;
         if (fixture == null)
            throw new Exception("Fixture does not implement IHasIUserState");

         fixture.UserState.FunctionVerifier = _verifier;
      }

      public void AfterTest(TestDetails testDetails)
      {
      }

      public ActionTargets Targets
      {
         get { return ActionTargets.Test; }
      }
   }


In 1.48.5 the BeforeTest is hit when I debug, in 2.4 it's not. Bit of a bummer that I now have failing tests :-(.
Hi,

Thanks for sharing this issue.

I've just run some tests on this myself but haven't had any luck in reproducing the issue. Is there any chance you could create a small cut-down solution reproducing the problem that you could share with me? You can submit any code via the contact form on this website - http://www.ncrunch.net/Support/Contact.


Cheers,

Remco
Hi John -

Sorry I've had no luck receiving your emailed attachment with this issue in it ... and your mail server seems to be blocking all replies I've sent to the email you contacted me with. It seems communication is being quite a challenge for us at the moment! Do you have a different email you can contact me with?


Cheers,

Remco
Hi Remco,

I updated my emailaddress in my account, you can use that.

John
Thanks John! From the code sample you've sent, I've managed to reproduce and analyse the issue.

The problem is caused by the NUnit.Framework.dll assembly being resolved twice inside the NCrunch test environment. NCrunch V2.X is packaged with NUnit 2.6.3, and the solution you're working with uses NUnit 2.6.2. Because of the version inconsistency, the framework DLL gets loaded twice each time under a different version. This skews the CLR's internal logic and causes some very strange things to happen inside NUnit.

Most NUnit features seem to be able to operate normally, but ITestAction appears to be different. The difference between assemblies causes NUnit's references to this interface to fail without a consistent pattern. This means that on some systems the problem appears, while other systems are perfectly OK.

The easiest solution is to just delete the file: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Remco Software\NCrunch for Visual Studio 2013\NUnit.Framework.dll

This file was never supposed to be included in the NCrunch installer, as there is no need for it when solutions already have it included. It only seems to be causing problems anyway. I'll ensure its removed for all future versions of NCrunch.

Thanks for all your help in getting to the bottom of this one.


Cheers,

Remco

Post a reply

Log in to reply.