如何在自动UI测试期间运行ASP.NET应用程序?

时间:2022-09-05 04:12:46

I have an ASP.NET application (specifically, it's an ASP.NET MVC application). I am wanting to write some MSTest tests for it that access it through the browser (using a library such as Selenium or WatiN).

我有一个ASP.NET应用程序(具体来说,它是一个ASP.NET MVC应用程序)。我想为它编写一些MSTest测试,通过浏览器访问它(使用Selenium或WatiN等库)。

In order for my UI tests to work, the ASP.NET application needs to be actually running in a web server so that it can be accessed through the browser. The application could be configured to run on IIS, IIS Express or Visual Studio Development Server. (I want all three configurations to be supported.)

为了使我的UI测试工作,ASP.NET应用程序需要实际在Web服务器中运行,以便可以通过浏览器访问它。可以将应用程序配置为在IIS,IIS Express或Visual Studio Development Server上运行。 (我希望支持所有三种配置。)

How can I ensure that the ASP.NET application is running on a web server when the tests are run?

运行测试时,如何确保ASP.NET应用程序在Web服务器上运行?

1 个解决方案

#1


1  

I would suggest using something like SpecsFor.Mvc

我建议使用像SpecsFor.Mvc这样的东西

http://specsfor.com/SpecsForMvc/

http://specsfor.com/SpecsForMvc/

It does a lot of the hard work for you. You write integration tests, just like you would write normal unit tests.

它为你做了很多艰苦的工作。您编写集成测试,就像您编写正常的单元测试一样。

When you run the tests, SpecsFor.Mvc applies your web config transforms, runs and hosts the app, and kicks off the tests in whichever browser you choose.

当您运行测试时,SpecsFor.Mvc会应用您的Web配置转换,运行并托管应用程序,并在您选择的任何浏览器中启动测试。

#1


1  

I would suggest using something like SpecsFor.Mvc

我建议使用像SpecsFor.Mvc这样的东西

http://specsfor.com/SpecsForMvc/

http://specsfor.com/SpecsForMvc/

It does a lot of the hard work for you. You write integration tests, just like you would write normal unit tests.

它为你做了很多艰苦的工作。您编写集成测试,就像您编写正常的单元测试一样。

When you run the tests, SpecsFor.Mvc applies your web config transforms, runs and hosts the app, and kicks off the tests in whichever browser you choose.

当您运行测试时,SpecsFor.Mvc会应用您的Web配置转换,运行并托管应用程序,并在您选择的任何浏览器中启动测试。