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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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
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?
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
I guess I was 3 minutes too slow.. :)
typo
various = variations
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.
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!
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
tolisss,
you sir, r a godsend
thanks,
finally, NUnitTestForm success