Testing ASP.NET webforms applications

后端 未结 3 696
伪装坚强ぢ
伪装坚强ぢ 2021-02-06 07:54

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 inexpens

3条回答
  •  忘了有多久
    2021-02-06 08:57

    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. 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.

提交回复
热议问题