ASP.NET - How do you Unit Test WebControls?

2020-04-02 07:13发布

Alright.

So I figure it's about time I get into unit testing, since everyone's been banging on about it for long enough. I've installed NUnit and gone through a few "intro to unit testing" type tutorials.

I'm currently putting together a small framework to help with the rebuild of one of our web apps, so I've created a VS2008 project for my framework and I want to unit test it as I go.

How on earth do I go about unit testing the WebControls? The methods are all protected or private, and since it's a framework, there isn't much else but WebControls.

Any pointers?

Burns

9条回答
我想做一个坏孩纸
2楼-- · 2020-04-02 07:36

You could also look at testing components through the browser as a user would see them using a testing framework such as WebAii. I've seen it work and its pretty cool. I've also been told you can plug it into automated builds but I've not seen that as of yet.

Hope it helps ...

查看更多
Deceive 欺骗
3楼-- · 2020-04-02 07:36

You can also take a look at this Rhino Igloo framework. It is a compromised MVC framework for WebForms.

查看更多
Explosion°爆炸
4楼-- · 2020-04-02 07:42

Ivonna can test WebControls in isolation, within the Asp.Net context Just call session.GetControl("Path.ascx") and verify that it has all necessary properties.

查看更多
登录 后发表回答