测试ASP.NET应用程序的WebForms [英] Testing ASP.NET webforms applications

查看:158
本文介绍了测试ASP.NET应用程序的WebForms的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果你在我的位置是你有已经升级到这一不可维护的东西一个大的WebForms应用程序。东西打破,当你添加新的功能,你需要一种廉价的维护的方式做一些自动化的测试。

If you're in my position you have a big WebForms applications which have escalated to this unmaintainable thing. Things break when you add new features and you need an inexpensive maintainable way to do some kind of automated testing.

现在,从我的理解,做正确的事情是尝试但建设ASP.NET WebForms的页面和用户控制模型$ P ​​$ psent的抽象布局,看到它需要在一个主要的投资现有的应用程序是不是一个选项。

Now, from my understanding, the right thing to do would be to try building an abstraction layout of the page and user control model present in ASP.NET WebForms however, seeing as it would require a major investment in an existing application it is not an option.

我想,推动尽可能一个REST式的发展,因为它有一些很好的特性。虽然这样做,我写了一个简单的蜘蛛机器人抓取的所有URL就可以找到并尝试,干脆让他们。
这让我很快找到坏的数据是造成问题,避免有我的最终用户点击破事,但是,这当然是不够的。

I'm trying and pushing for a REST-like development as much as possible because it has some nice properties. And while doing this I've written a simple spider bot that crawls all URLs it can find and tries, simply getting them. This allowed my to quickly find bad data that was causing problems and avoid having my end-users clicking on broken things, however, this is of course not enough.

我继续我的工作,履带式和它的发展成为尝试不同的输入组合,寻找一个可能的错误或崩溃简单的REST客户端。这是更智能,只是穷举搜索(因为它知道有关ASP.NET的WebForms应用层),并在这里我的目标是基本探索网络应用程序的状态,希望我们的用户之前打所有的极端案例。

I continued work on my crawler and it's developed into a simple REST client that tries different input combination, looking for a probable bug or crash. It's more intelligent that just an exhaustive search (because it knows about the ASP.NET WebForms application layer) and my goal here is to basically explore the state of the web application, hoping to hit all the corner cases before our users.

没有人有任何经验做类似的东西?

Does anyone have any experience doing something similar?

另外,对于你测试大师那里。这是完全是浪费时间,否则我将能够真正说说这里的质量?从我的角度来看,它似乎击中甜蜜点,它会尝试的东西潜在的终端用户会虽然浏览器。

Also, for you test gurus out there. Is this a complete waste of time, or will I be able to actually say something about the quality here? From my perspective it seems to hit a sweet spot in that it will try things a potential end user would though a browser.

正如我以前说过,我们坚持在一个不好的地方。我们需要一种简单的方法了吧,现在。

As I said before, we're stuck in a bad place. And we need a simple way out of it, right now.

我们已经尝试过类似的事情硒,但它的任务很多额外的工作,我们改变的东西的时候,它只是没有可能维持多Selenium测试服50不同的应用。

We've tried things like Selenium, but it mandates a lot of extra work and we change things all the time, it's just no possible to maintain multiple selenium test suits for 50 different applications.

推荐答案

所有类型的测试实行,单元测试既是最简单,最容易见效,在更短的缺陷而言,更易于维护code。获取制定出你处理自动化集成测试前

Of all the types of testing to implement, unit testing is both the easiest and the most likely to yield results, in terms of less bugs and more maintainable code. Get that worked out before you deal with automated integration testing


  1. 选择一个IoC容器 - 我喜欢 Ninject 此亲自

  2. 找到一个方便的地方注入服务类到您的网页(基Page类的consturctor或覆盖加载页面模块,无论你的作品)

  3. 选择一个单元测试框架,如果你没有一个自动构建然后设置一个;包括在运行构建一套完整的单元测试

  4. 每次你去附近在aspx.cs文件中的逻辑块,看看如果你不能在服务隔离,并环绕它的单​​元测试

  5. 看看在 MVP模式是否将有利于你 - 我们发现它的生产力尽可能多的减少,因为它增加了可测试性(它确实都很多),但它的作品对某些人

  6. 查看关于慢慢地迁移应用MVC,的在一个时间一个页面,如果必要

  1. Pick an IOC Container - I like Ninject for this personally
  2. Find a convenient place to inject "service" classes into your Page (the consturctor of a base Page class or override the module that loads pages, whatever works for you)
  3. Pick a unit test framework and if you don't have an automated build then set one up; include running a full suite of unit tests in that build
  4. Every time you go near a piece of logic in an aspx.cs file, see if you can't isolate it in a service and wrap unit tests around it
  5. Take a look at whether the MVP Pattern would be good for you - we found it decreased productivity as much as it increased testability (it did both a lot), but it works for some people
  6. See about slowly migrating your app over to MVC, a page at a time if necessary

记住,你是不会在一夜之间解决这个问题,你没有时间。只要保持改进测试覆盖率,你会看到随着时间的好处。

And remember, you are not going to fix this problem overnight, you don't have time. Just keep improving test coverage and you'll see the benefits over time.

这篇关于测试ASP.NET应用程序的WebForms的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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