在单元测试期间显示 winform [英] Show winform during unit test

查看:38
本文介绍了在单元测试期间显示 winform的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在单元测试期间我在显示 winform 时遇到了一些麻烦.我将此用作用户验证的测试程序,以向用户显示 Selenium UI 测试期间捕获的 2 个不同的图像片段以及它们之间的差异,并允许用户根据图像是否太不同来通过或失败测试.

I'm having a bit of trouble showing a winform during a unit test. I'm using this as a user validated testing procedure to show the user 2 different image segments captured during Selenium UI testing and the diff between them and allowing the user to pass or fail the test based on whether or not the images are too different.

我创建了包含 2 个 PictureBox 元素的表单,并向表单添加了方法,以允许表单接收我需要的图像并将它们加载到 PictureBox 中,然后显示表单.

I've created the form with 2 PictureBox elements and added methods to the form to allow the form to take in the images I require and load them into the PictureBox and then show the form.

我试过在 google + SO 上搜索,但找不到任何类似的问题.

I've tried searching google + SO and I can't find any similar questions regarding this.

在我的测试中,我有:

var compareForm = new PlotCompare.PlotCompare();
compareForm.Add_Original_Image(image1);
compareForm.Add_Diff_Image(imageDiff);
compareForm.Show();

但是 .Show(); 调用不显示表单.

but the .Show(); call doesn't show the form.

我能合理想到的唯一问题是我正在使用的项目是一个类库,因为它包含的所有内容都是测试,因此没有我可以访问的 main 函数.

The only issue I can reasonably think of is that the project I'm using is a class library because all it holds are tests and therefore doesn't have a main function I can access.

非常感谢您的帮助,提前致谢.

Would appreciate any help, thanks in advance.

推荐答案

https://stackoverflow.com/a/34799721/3110529 回答这个问题,本质上是将表单的 ShowInTaskbar 属性设置为 False 它会按预期显示!

https://stackoverflow.com/a/34799721/3110529 Answered this, essentially setting the ShowInTaskbar property of the form to False it would show as expected!

我还必须使用 .ShowDialog() 而不仅仅是 .Show()

I also had to use .ShowDialog() rather than just .Show()

这篇关于在单元测试期间显示 winform的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆