简体   繁体   English

如何在ASP.NET webforms中应用单元测试

[英]How apply Unit tests in ASP.NET webforms

I'm developing a website in asp.net webforms with 3 layers; 我正在开发一个包含3层的asp.net webforms网站; UI, BLL and DAL The website is already developed, but i like have more control about the unit tests of each form UI,BLL和DAL网站已经开发,但我喜欢对每个表单的单元测试有更多的控制权

Pass specific values at specific inputs for i see, if application survives or not. 如果应用程序存活或未存在,请在特定输入处传递特定值。

I already study about NUnit but in webforms in UI layer how can apply these tests? 我已经研究过NUnit但是在UI层的webforms中如何应用这些测试?

What i wnat is get some way to test UI (validations) without have to access to the BLL as i was an user. 我想知道是什么方式来测试UI(验证)而不必访问BLL,因为我是一个用户。

I'm trying to add the Unit tests to my app but i not sure how to do it! 我正在尝试将单元测试添加到我的应用程序,但我不知道该怎么做!

somebody can help my small-bigger problem? 有人可以帮我解决我的小问题吗?

You can add unit test to your UI using one of these tools 您可以使用这些工具之一将单元测试添加到UI

With both tools you can generate C# or VB classes that can be used by NUnit. 使用这两种工具,您可以生成NUnit可以使用的C#或VB类。 IMHO, UI test are not as reliable as the common unit tests. 恕我直言,UI测试不如普通单元测试可靠。 Bacause timing conditions you may randomly find that some test will fail. 因为暂停时间条件,您可能会随机发现某些测试会失败。

I used both tools and I recommend selenium mainly because you can generate test that can be run against any browser. 我使用了这两种工具,我推荐selenium主要是因为你可以生成可以针对任何浏览器运行的测试。

Here an example how to use Watin with NUnit http://www.codeproject.com/KB/applications/SimpleUITestHarness.aspx 这里有一个如何在NUnit中使用Watin的例子http://www.codeproject.com/KB/applications/SimpleUITestHarness.aspx

And here a guide how to use Seleniun with Nunit http://www.lostechies.com/blogs/agilecruz/archive/2009/02/10/how-to-configure-selenium-rc-for-use-in-c-nunit-tests.aspx 这里有一个如何将Seleniun与Nunit一起使用的指南http://www.lostechies.com/blogs/agilecruz/archive/2009/02/10/how-to-configure-selenium-rc-for-use-in-c- NUnit的,tests.aspx

If I understand your question correctly, you're asking how to automate testing a WebForms UI. 如果我正确理解您的问题,您就会问如何自动测试WebForms UI。 If I misunderstand, please correct this understanding. 如果我误解了,请纠正这种理解。

Frankly, I don't think there is a good answer out there for this. 坦率地说,我认为没有一个好的答案。 There are two options, however, that work okay : 有两种选择,但是,工作

  1. Visual Studio Test Edition Visual Studio测试版
  2. Telerik's Web Testing (both a free version and a version with a cost) Telerik的Web测试 (免费版和带有成本的版本)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM