Is it possible to display a windows Form from within unit tests?
up vote
0
down vote
favorite
So i'm writing this computer vision application in C# using opencv, Emgu and visual studio.
I'm trying to write a few unit tests using the built in unit tests from Microsoft and I'm starting to think that I'm trying to do something really rare here because I simply can't find the answer anywhere on the internet.
The application is a console application because it won't have a user interface but I'd like to display a few debug images while I'm coding it. I have created a Form using the designer which has a few PictureBox
in it.
I simply would like to be able to do something like:
DebugViewer debugViewer = new DebugViewer();
debugViewer.SetPicture(debugImage);
debugViewer.Show();
Where DebugViewer
is the Form
I created and SetPicture
simply updates the image of a PictureBox
.
The problem is that the form never shows up. Nothing appears in the taskbar even with the ShowInTaskbar
property set.
I tried the same code running from a main function and it worked correctly. The problem seems to be with trying to run this from a unit test.
I also successfully displayed images using opencv imShow
function even from the unit tests so I'm certain it is possible to open windows from unit tests but I don't know why the Forms don't show up.
I realize opening debug windows from unit test doesn't make much sense but since I've lost an entire afternoon trying to solve this I thought I should at least satisfy my curiosity.
Thanks a lot.
c# winforms visual-studio unit-testing opencv
add a comment |
up vote
0
down vote
favorite
So i'm writing this computer vision application in C# using opencv, Emgu and visual studio.
I'm trying to write a few unit tests using the built in unit tests from Microsoft and I'm starting to think that I'm trying to do something really rare here because I simply can't find the answer anywhere on the internet.
The application is a console application because it won't have a user interface but I'd like to display a few debug images while I'm coding it. I have created a Form using the designer which has a few PictureBox
in it.
I simply would like to be able to do something like:
DebugViewer debugViewer = new DebugViewer();
debugViewer.SetPicture(debugImage);
debugViewer.Show();
Where DebugViewer
is the Form
I created and SetPicture
simply updates the image of a PictureBox
.
The problem is that the form never shows up. Nothing appears in the taskbar even with the ShowInTaskbar
property set.
I tried the same code running from a main function and it worked correctly. The problem seems to be with trying to run this from a unit test.
I also successfully displayed images using opencv imShow
function even from the unit tests so I'm certain it is possible to open windows from unit tests but I don't know why the Forms don't show up.
I realize opening debug windows from unit test doesn't make much sense but since I've lost an entire afternoon trying to solve this I thought I should at least satisfy my curiosity.
Thanks a lot.
c# winforms visual-studio unit-testing opencv
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
So i'm writing this computer vision application in C# using opencv, Emgu and visual studio.
I'm trying to write a few unit tests using the built in unit tests from Microsoft and I'm starting to think that I'm trying to do something really rare here because I simply can't find the answer anywhere on the internet.
The application is a console application because it won't have a user interface but I'd like to display a few debug images while I'm coding it. I have created a Form using the designer which has a few PictureBox
in it.
I simply would like to be able to do something like:
DebugViewer debugViewer = new DebugViewer();
debugViewer.SetPicture(debugImage);
debugViewer.Show();
Where DebugViewer
is the Form
I created and SetPicture
simply updates the image of a PictureBox
.
The problem is that the form never shows up. Nothing appears in the taskbar even with the ShowInTaskbar
property set.
I tried the same code running from a main function and it worked correctly. The problem seems to be with trying to run this from a unit test.
I also successfully displayed images using opencv imShow
function even from the unit tests so I'm certain it is possible to open windows from unit tests but I don't know why the Forms don't show up.
I realize opening debug windows from unit test doesn't make much sense but since I've lost an entire afternoon trying to solve this I thought I should at least satisfy my curiosity.
Thanks a lot.
c# winforms visual-studio unit-testing opencv
So i'm writing this computer vision application in C# using opencv, Emgu and visual studio.
I'm trying to write a few unit tests using the built in unit tests from Microsoft and I'm starting to think that I'm trying to do something really rare here because I simply can't find the answer anywhere on the internet.
The application is a console application because it won't have a user interface but I'd like to display a few debug images while I'm coding it. I have created a Form using the designer which has a few PictureBox
in it.
I simply would like to be able to do something like:
DebugViewer debugViewer = new DebugViewer();
debugViewer.SetPicture(debugImage);
debugViewer.Show();
Where DebugViewer
is the Form
I created and SetPicture
simply updates the image of a PictureBox
.
The problem is that the form never shows up. Nothing appears in the taskbar even with the ShowInTaskbar
property set.
I tried the same code running from a main function and it worked correctly. The problem seems to be with trying to run this from a unit test.
I also successfully displayed images using opencv imShow
function even from the unit tests so I'm certain it is possible to open windows from unit tests but I don't know why the Forms don't show up.
I realize opening debug windows from unit test doesn't make much sense but since I've lost an entire afternoon trying to solve this I thought I should at least satisfy my curiosity.
Thanks a lot.
c# winforms visual-studio unit-testing opencv
c# winforms visual-studio unit-testing opencv
asked Dec 25 '15 at 22:46
Felipe Castro
43
43
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
Is your debugViewer form shown modally or non-modally? I was just playing with unit testing and trying to display a report preview form I have. When I display the form modally, it works. When I display it non-modally, nothing displays.
I imagine that displaying a form non-modally, where execution continues, takes everything out of scope as the unit test ends. That means the form does not display. Or, perhaps the unit testing code knows it can't display anything unless execution stops and never even displays it? Not sure. So far, though, I have been able to make several different forms pop up inside unit test methods.
(I am sure this is not a very good answer, but I don't have the points to simply comment yet...)
EDIT: I have run into modal forms that also do not display, and I cannot figure out why. I can debug the test, and when it comes to the line where my form is being displayed with ShowDialog(), execution pauses but no form displays. I can even inspect the form in the debug window and see that its dimensions are correct and Visible = true -- still nothing. So, I'm stumped.
add a comment |
up vote
0
down vote
I think you are trying to use the wrong tool for your problem... Dealing with GUI just for debug purpose can be frustrating...
Check out HypnoLog, an open source tool I developed to help me debug image processing application I been writing using C# and EmguCV.
With HypnoLog you can see the images as output in your browser, which acting as output log.
In your case you should check HypnoLog-CSharp, and there is already a simple visualizer for images. Your code will look something like this:
HL.log(debugImage, "image");
note, debugImage
should be image encoded in base64
, see ImageVisualizer
for more information.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Is your debugViewer form shown modally or non-modally? I was just playing with unit testing and trying to display a report preview form I have. When I display the form modally, it works. When I display it non-modally, nothing displays.
I imagine that displaying a form non-modally, where execution continues, takes everything out of scope as the unit test ends. That means the form does not display. Or, perhaps the unit testing code knows it can't display anything unless execution stops and never even displays it? Not sure. So far, though, I have been able to make several different forms pop up inside unit test methods.
(I am sure this is not a very good answer, but I don't have the points to simply comment yet...)
EDIT: I have run into modal forms that also do not display, and I cannot figure out why. I can debug the test, and when it comes to the line where my form is being displayed with ShowDialog(), execution pauses but no form displays. I can even inspect the form in the debug window and see that its dimensions are correct and Visible = true -- still nothing. So, I'm stumped.
add a comment |
up vote
0
down vote
Is your debugViewer form shown modally or non-modally? I was just playing with unit testing and trying to display a report preview form I have. When I display the form modally, it works. When I display it non-modally, nothing displays.
I imagine that displaying a form non-modally, where execution continues, takes everything out of scope as the unit test ends. That means the form does not display. Or, perhaps the unit testing code knows it can't display anything unless execution stops and never even displays it? Not sure. So far, though, I have been able to make several different forms pop up inside unit test methods.
(I am sure this is not a very good answer, but I don't have the points to simply comment yet...)
EDIT: I have run into modal forms that also do not display, and I cannot figure out why. I can debug the test, and when it comes to the line where my form is being displayed with ShowDialog(), execution pauses but no form displays. I can even inspect the form in the debug window and see that its dimensions are correct and Visible = true -- still nothing. So, I'm stumped.
add a comment |
up vote
0
down vote
up vote
0
down vote
Is your debugViewer form shown modally or non-modally? I was just playing with unit testing and trying to display a report preview form I have. When I display the form modally, it works. When I display it non-modally, nothing displays.
I imagine that displaying a form non-modally, where execution continues, takes everything out of scope as the unit test ends. That means the form does not display. Or, perhaps the unit testing code knows it can't display anything unless execution stops and never even displays it? Not sure. So far, though, I have been able to make several different forms pop up inside unit test methods.
(I am sure this is not a very good answer, but I don't have the points to simply comment yet...)
EDIT: I have run into modal forms that also do not display, and I cannot figure out why. I can debug the test, and when it comes to the line where my form is being displayed with ShowDialog(), execution pauses but no form displays. I can even inspect the form in the debug window and see that its dimensions are correct and Visible = true -- still nothing. So, I'm stumped.
Is your debugViewer form shown modally or non-modally? I was just playing with unit testing and trying to display a report preview form I have. When I display the form modally, it works. When I display it non-modally, nothing displays.
I imagine that displaying a form non-modally, where execution continues, takes everything out of scope as the unit test ends. That means the form does not display. Or, perhaps the unit testing code knows it can't display anything unless execution stops and never even displays it? Not sure. So far, though, I have been able to make several different forms pop up inside unit test methods.
(I am sure this is not a very good answer, but I don't have the points to simply comment yet...)
EDIT: I have run into modal forms that also do not display, and I cannot figure out why. I can debug the test, and when it comes to the line where my form is being displayed with ShowDialog(), execution pauses but no form displays. I can even inspect the form in the debug window and see that its dimensions are correct and Visible = true -- still nothing. So, I'm stumped.
edited Jan 13 '16 at 21:41
answered Jan 13 '16 at 20:22
sutekh137
353214
353214
add a comment |
add a comment |
up vote
0
down vote
I think you are trying to use the wrong tool for your problem... Dealing with GUI just for debug purpose can be frustrating...
Check out HypnoLog, an open source tool I developed to help me debug image processing application I been writing using C# and EmguCV.
With HypnoLog you can see the images as output in your browser, which acting as output log.
In your case you should check HypnoLog-CSharp, and there is already a simple visualizer for images. Your code will look something like this:
HL.log(debugImage, "image");
note, debugImage
should be image encoded in base64
, see ImageVisualizer
for more information.
add a comment |
up vote
0
down vote
I think you are trying to use the wrong tool for your problem... Dealing with GUI just for debug purpose can be frustrating...
Check out HypnoLog, an open source tool I developed to help me debug image processing application I been writing using C# and EmguCV.
With HypnoLog you can see the images as output in your browser, which acting as output log.
In your case you should check HypnoLog-CSharp, and there is already a simple visualizer for images. Your code will look something like this:
HL.log(debugImage, "image");
note, debugImage
should be image encoded in base64
, see ImageVisualizer
for more information.
add a comment |
up vote
0
down vote
up vote
0
down vote
I think you are trying to use the wrong tool for your problem... Dealing with GUI just for debug purpose can be frustrating...
Check out HypnoLog, an open source tool I developed to help me debug image processing application I been writing using C# and EmguCV.
With HypnoLog you can see the images as output in your browser, which acting as output log.
In your case you should check HypnoLog-CSharp, and there is already a simple visualizer for images. Your code will look something like this:
HL.log(debugImage, "image");
note, debugImage
should be image encoded in base64
, see ImageVisualizer
for more information.
I think you are trying to use the wrong tool for your problem... Dealing with GUI just for debug purpose can be frustrating...
Check out HypnoLog, an open source tool I developed to help me debug image processing application I been writing using C# and EmguCV.
With HypnoLog you can see the images as output in your browser, which acting as output log.
In your case you should check HypnoLog-CSharp, and there is already a simple visualizer for images. Your code will look something like this:
HL.log(debugImage, "image");
note, debugImage
should be image encoded in base64
, see ImageVisualizer
for more information.
answered Nov 8 at 23:57
Simon Ldj
111
111
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f34467064%2fis-it-possible-to-display-a-windows-form-from-within-unit-tests%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown