Menu

Stuck

Help
2004-12-08
2013-04-24
  • Randy Charles Morin

    I created a simple EXE that referenced one of my DLLs. I then wrote one empty test as follows.

    [NUnit.Framework.TestFixture]
    public class CommentForm : NUnit.Extensions.Forms.NUnitFormTest
    {

       public CommentForm()
       {
       }

       ss.PictureBar.CommentForm form = null;
       [NUnit.Framework.SetUp]
       public void SetUp()
       {
          form = new ss.PictureBar.CommentForm();
          form.Show();
       }

       [NUnit.Framework.Test]
       public void Test()
       {
       }

    }

    This generates the following failures from the NUnit GUI.

    --TearDown
       at NUnit.Extensions.Forms.NUnitFormTest.Verify()
    test.Forms.CommentForm.Test :
    TearDown : System.NullReferenceException : Object reference not set to an instance of an object.

    I tried a thousand variations of this trivial test w/out success. Well, except the one variation where you remove the NUnitFormTest inheritance. Then it works just fine ;)

    Any help would be awesome. Obviously, I'm just not getting it.

     
    • Michael Simpson

      Michael Simpson - 2004-12-08

      Randy,
      Instead of:

      [NUnit.Framework.SetUp]
      public void SetUp()

      try this:

      public override void Setup()

      The NUnitFormTest defines the [Setup] tag and apparently NUnit doesn't like it defined more than once.  So just override the method and you should be good to go.

      Good luck,
         Mike

       
      • Randy Charles Morin

        Yes, I have tried a million various on this theme already. With the noted change, I then get...

        test.Forms.BloomForm.Test :
        TearDown : System.ComponentModel.Win32Exception : The requested resource is in use

        --TearDown
           at NUnit.Extensions.Forms.Desktop.Destroy()
           at NUnit.Extensions.Forms.NUnitFormTest.Verify()

        Any other ideas?

         
    • Luke Maxon

      Luke Maxon - 2004-12-08

      Sorry for your pain. :)

      The answer is that you should not use the nunit setup attribute in a test that derives from NUnitFormTest.  Instead, you should override the virtual setup method in the base class for that purpose.  NUnit does not deal well (IMO) with having a [Setup] attribute on two classes in a class hierarchy.  (The base class uses it; you should not)

      Hope this helps,

      Luke

       
      • Luke Maxon

        Luke Maxon - 2004-12-08

        I guess I was 3 minutes too slow.. :)

         
    • Randy Charles Morin

      typo

      various = variations

       
    • Michael Simpson

      Michael Simpson - 2004-12-13

      I haven't seen that one which makes me suspect the problem is specific to something your test is doing, rather than a problem with the framework itself.  Have you been able to identify which resource is in use?  Maybe if you post your test class, something might jump out at us.

       
    • An Tay Nguy

      An Tay Nguy - 2004-12-13

      Hi,

      I also get this error too.  I noticed that if I use the RichEdit or the PropertyGrid control on my form, I will get this error.

      System.ComponentModel.Win32Exception : The requested resource is in use.

      --TearDown
      at NUnit.Extensions.Forms.Desktop.Destroy()
      at NUnit.Extensions.Forms.Desktop.Dispose()
      at NUnit.Extensions.Forms.NUnitFormTest.Verify()

      I am using VS 2003 with NUnit 2.2.2

      If anyone have any idea, please let me know too...

      Cheers!

       
      • A.Bekiaris

        A.Bekiaris - 2004-12-13

        u could override the UseHidden property of NUnitFormTest and set it to false that will fix it.
        I do not know of a better way that is how i use the framework

         
        • Randy Charles Morin

          tolisss,
          you sir, r a godsend
          thanks,
          finally, NUnitTestForm success

           

Log in to post a comment.