开发者

BDD with Specflow and mocking browser behavior

开发者 https://www.devze.com 2023-03-17 15:52 出处:网络
I\'ve started using SpecFlow to try to write specs for one of my ASP.NET MVC web application. I came across two basic questions for which I didnt find any answer in google.

I've started using SpecFlow to try to write specs for one of my ASP.NET MVC web application. I came across two basic questions for which I didnt find any answer in google.

  1. Is there a way to imitate the browser behavior without having to create a actual browser instance. I know there are libraries such as "WatiN" which enables creating actual browser instances and I'm reluctant to use it as it might significantly reduce the test performance (I need to run them in a build server)

  2. The reason why I need to depend on a Browser or a mock browser is that I do not want to direct my test on the controllers as it does not guarantee that all my action filters are fired when i instantiate a controller directly (as it is a part of asp.net mvc engin开发者_Python百科e). Can someone suggest me a approach to scenario test my controller -with all the action filters fired up ( so that I might not want to use a browser/mock browser)?

Thanks

Bumble Bee


If you want to test your HTTP pipeline you need something like WatiN or you must manually execute HTTP requests = for each test you must manually catch request and create the same one with WebClient or HttpWebRequest in your test. I would use WatiN because it makes real end-to-end tests.

It is also not true that tests running on build server must be fast - we have several sets of tests and some of them run several hours.


I would check out the Mara project (https://github.com/remi/Mara) that is a Capybara (a ruby tool) clone for .net.

Not only does Mara make it easier to write your test but also it allows you to pick and chose how to run your tests; with selenium, WatIn or headless and even using the WebClient mentioned above. In most cases it's just configuration.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号