Unit Test ASP.net Page_Load

后端 未结 3 997
日久生厌
日久生厌 2021-01-18 03:22

How can create a unit test for the the Page_Load function in ASP.net?

I am using build in Visual Studio Unit test frame work. I want to create a unit test that check

相关标签:
3条回答
  • 2021-01-18 03:42

    Web forms really wasn't built to be run through unit testing. Here's a good article on what I'm talking about. If you really want your pages to be testable I'd consider moving over to asp.net mvc or mvp.

    0 讨论(0)
  • 2021-01-18 03:44

    If you want testable ASP.NET WebForms code, check out this project. http://webformsmvp.com/

    0 讨论(0)
  • 2021-01-18 03:47

    You're probably not going to be able to new up a Page outside of the ASP.NET runtime.

    You may want to google around for the MVP (Model-View-Presenter) pattern under ASP.NET. It makes testing web code a lot easier IMHO. This article is a good starting point:

    http://haacked.com/archive/2006/08/09/ASP.NETSupervisingControllerModelViewPresenterFromSchematicToUnitTestsToCode.aspx

    0 讨论(0)
提交回复
热议问题