Suggestions for unit test loop

Experienced users,

I am looking for a better way of doing a unit test to test some visual aspects of my DirectX app. Cause the method I am using will sometimes leave the unit test running until .net fells like stoping it. And if the unit test window is not visible the cpu spikes while I am trying to do other things. (I use the little to the left of the test methods most of the time)

Here is what I am currently doing


public void Test()
{
Form frm = new Form();
frm.Show();

do
{
// do something here
Application.DoEvents();
}
while (frm.Visible);

Assert.AreEqual(1,1);
}

There is no assert test I can do to visually tell if shading or such things are working so..... that is why I must visually look.

My issue with this is that the unit tests do not end when I hit the X on the form that is created while running the test.

Is there a better way of creating a form and looping until the form is closed in a unit test?

Thanks for any direction.

2 comments
Comment actions Permalink

Hello Chris,

perhaps I'm missing something, but why do you need a unit test in the first
place? As far as I understand your
unit test anyway needs user attention in order to decide if it has failed
or completed successfully. Wouldn't it be better
to just add a simple WinForms application project to your solution that would
show the form with all necessary visual effects
just like the unit test does, and run / debug this project instead of the
unit test?

Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


Experienced users,

I am looking for a better way of doing a unit test to test some visual
aspects of my DirectX app. Cause the method I am using will sometimes
leave the unit test running until .net fells like stoping it. And if
the unit test window is not visible the cpu spikes while I am trying
to do other things. (I use the little to the left of the test methods
most of the time)

Here is what I am currently doing


public void Test()
{
Form frm = new Form();
frm.Show();
do
{
// do something here
Application.DoEvents();
}
while (frm.Visible);
Assert.AreEqual(1,1);
}
There is no assert test I can do to visually tell if shading or such
things are working so..... that is why I must visually look.

My issue with this is that the unit tests do not end when I hit the X
on the form that is created while running the test.

Is there a better way of creating a form and looping until the form is
closed in a unit test?

Thanks for any direction.



0
Comment actions Permalink

Dmitry, thanks for the reply and I do see your point. I am building a fairly large DX framework and the windows forms test project would work.

I do have alot of tests that can be verified by nunit asserts, and alot that cannot be. But, I do want to keep all testing in one place. Hence I was trying to do the user verified tests there as well. The primart developer of the game Rocket Commander from the Coding4Fun website also uses a similar method for testing. (form creation from within unit tests)

I did forget to put in the Assert in some of the test methods. Adding those seems to have helped, but is still as not as responsive as I thought it would be (don't think that has anything to do with R# though).

But still looking for a better method of catching form closing instead of visibility.

In the end I think my issue is unreleated to R# and has more to do with nunit and my workflow.

Thanks again,

0

Please sign in to leave a comment.