有人用过 Steve Sanderson 的 MvcIntegrationTestFramework 吗?
我正在寻找测试 ASP.NET MVC 应用程序的其他方法,并遇到了 Steve Sanderson 的 MvcIntegrationTestFramework. 这种方法看起来很有前途,但我想知道是否有人有任何实际经验可以分享。
I was looking into additional ways to test ASP.NET MVC applications and ran into Steve Sanderson’s MvcIntegrationTestFramework. The approach looks rather promising but I was wondering if anyone had any actual experience to share.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我从中得到了一些非常好的结果。 我不在乎这里的其他人怎么说需要测试视图,一旦您将第一行代码添加到视图中,即使代码严格与表示相关,您也会引入潜在的错误,其中编写自动化测试是个好主意。 我的主要兴趣是捕获尽可能多的白屏和黄屏异常/错误。 为此,我一直在使用 Steven 的介绍性博客文章中的片段来确保页面正确呈现,而不会引发任何异常:
我在这个框架中看到的小陷阱可能是:
var result =浏览Session.ProcessRequest("/account/logon", HttpVerbs.Post, new NameValueCollection
{
{"用户名","我的名字"},
{"密码", "我的密码"},
{“returnUrl”,“/home/myActionMethod”}
});
I'm having some really good results from it. I don't care what anyone else on here says about the need to test views, as soon as you add your first line of code to a view, even if the code is strictly presentation-related, you introduce a potential for errors for which it would be a good idea to write automated tests. My primary interest is just to catch as many white screen and yellow screen exception/errors as possible. To do so I have been using the snippet from Steven's introductory blog post to ensure that the page rendered properly without throwing any exceptions:
The small pitfalls that I see with this framework might be:
var result = browsingSession.ProcessRequest("/account/logon", HttpVerbs.Post, new NameValueCollection
{
{"UserName","myName"},
{"Password", "myPassword"},
{"returnUrl", "/home/myActionMethod"}
});
不久前阅读了 ardave 的回答后,我们实际上自己去尝试一下我们的新 Orchard 基于应用程序 Marinas.info。
首先,我建议任何人从此版本的分支开始,因为它更容易设置比原来的。
对于任何“普通”MVC3 应用程序来说,它都可以正常工作。 不幸的是,与 Orchard 一起使用时效果不佳,至少与未经修改的 Global.asax.cs 版本一起使用时效果不佳。 所以我们仍然继续 基于浏览器的测试之路,但我们继续使用它在内部执行 Orchard 命令该应用程序足够快。
After reading ardave's answer a while ago, we actually went to try it out for ourselves for our new Orchard based application Marinas.info.
First of all, I recommend anyone to start from a fork of this version as it's even easier to set up than the original.
For any "normal" MVC3 app it simply works. Unfortunately, together with Orchard it didn't play well, at least not with an unmodified version of their Global.asax.cs. So we still went down the browser based testing road but we keep using it to execute Orchard commands inside the app which is fast enough.
我没用过这个框架。 但根据我阅读他的书的经验 -Pro ASP.NET MVC Framework ,以及他开发的另一个验证框架 xVal,我会说“他很棒”。
I haven't used this framework. But based on my experience of reading his book -Pro ASP.NET MVC Framework, and another validation framework xVal he developed, I would say "HE IS GREAT".
稍微尝试一下,它在某些情况下可能非常有用。 普遍竖起大拇指,如果我看到进一步的工作,我将在未来的项目中使用。
没有继续进行,因为已经有 WatIn 设置并处理了一些我不想再次处理的事情在这个框架内。 例如,通过对话框进行身份验证,这可能需要更改代码。
Experimented with it a little and it could be very useful in some situations. General thumbs up and if I saw further work on it I would use on a future project.
Didn't proceed as already have WatIn setup and taking care of some things I wouldn't like to tackle again in this framework. E.g. authentication through a dialog, which would probably require a code change.