Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Winforms not closing after a test is completed
sgrassie
#1 Posted : Friday, August 21, 2015 9:48:12 AM(UTC)
Rank: Member

Groups: Registered
Joined: 6/25/2015(UTC)
Posts: 15
Location: United Kingdom

Thanks: 2 times
Was thanked: 3 time(s) in 3 post(s)
First, let's put aside the wisdom of avoiding writing unit tests which do anything with winforms. Sometimes you just have to suck it up :(

My test(s) looks like this:

Code:

        [Test, RequiresSTA]
        public void SomeTest()
        {
            using (var form = new SomeForm())
            {
                // Arrange

                // Act

               // Assert
            }
        }


My issue is that since moving to Windows 10, the forms don't close. If I kill the nCrunch.TestHost45.x86.exe process which is hosting them, they obviously do close.

On windows 8.1, this wasn't a problem - I just had to live with the annoyance of having the forms momentarily flash up if I happened to modify any code which impacted those tests.

I'm on the latest version of NCrunch, VS2013 (fully updated) and Windows 10.
Remco
#2 Posted : Friday, August 21, 2015 11:17:37 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for sharing this issue.

I find it a little disturbing that disposing of a form isn't closing it in the Windows 10 UI. I hope that we haven't discovered yet another Windows 10 UI bug ...

NCrunch has no real awareness of UI, it just relies on your own code to do its thing. I have a feeling that this bug is bigger than NCrunch itself, so I'm afraid that I can't provide a direct fix for the problem (you might need to take it up with MS), but I might be able to provide you with a workaround.

NCrunch has a configuration setting that will terminate a test runner process as soon as its run has completed. This should prevent the process from sticking around after the run and allow the window to be forced closed when it terminates. If you have a long test run, it might be worth marking the test with the Isolated attribute to force the process to terminate immediately as the test completes, rather than sticking around until the whole run is finished.

If you're performing UI testing with dialogs appearing, I highly recommend you look into distributed processing. This will let you offload all the irritating UI testing to a different machine, keeping your development experience clean and clear. If you don't have any spare hardware to offload to, a simple VM hosted on your dev machine should still be enough to remove the interference.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.026 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download