I agree with you all guys. The controller-level BDD experience really
rocks, nothing compares to that. But I have seen many teams using
SpecFlow where they have finally went into the web testing direction.
These are the usual arguments:
- If the application is AJAX intensive, there are quite much logic in
the web part, that is anyway harder to test with classic approaches.
- The
ASP.NET MVC framework can do quite much on top of the
controllers: bindings, filters, validation, path routing, etc. With
controller-level testing, you are bypassing these.
- If a feature is a combination of UI (javascript, WPF xaml, etc.) and
backend (from controller on) logic, it is hard to find the right way
for testing it half. This can be a source of an endless discussions.
- The automated testing efforts are significant, even if you do it
over the controller. If such investment is made, business is
interested in guarding the end-to-end quality.
I'm not saying that these apply for all projects, but should be
considered. In some of our project we also use the MvcIntegrationTest
framework from Steven Sanderson as an in-between solution.
For me, personally, there is no _fundamental_ difference of the two
testing approaches. Controller is just an in-between layer of your
application and has no relevance of the "behavior", that BDD suppose
to target. It's another question that the through-UI testing has much-
much less good and reliable tool support. So my hope is, that as the
UI testing (and implementation) tools and practices improve (and they
are improving quite fast), the difference will be smaller and smaller.
So with one hand of mine, I do my controller-level BDD tests
(accepting it as a good compromise), but with the other hand i'm
trying to improve the tools to make the UI testing better. Nice
mission, isn't it? ;-)
Br,
Gaspar
On Mar 4, 6:18 pm, Darren Cauthon <
darrencaut...@gmail.com> wrote:
> Pedro,
>
> I agree with you, and SpecFlow does not require or even lean towards
> testing through the UI. I've seen many who say we should, that we
> should test the "entire" application, but you can also find the other
> side.
>
> Personally, I think complexity kills automated tests, and introducing
> the UI is one of the most complex things you can bring into tests.
> The UI adds other potential failures, it makes faking parts more
> difficult, it slows them down, and it makes asserting results
> difficult. I mean, how could it not? The UI has a very limited view
> of the application, and running the website has to happen through a
> web server which will happen on a different process makes it hard to
> test results.
>
> I've had much more success testing against the controller level with
> ASP.Net MVC. Everything happens within the same thread, you can
> easily create everything that goes in, everything that comes out, and
> you're missing only the views.
>
> It makes for a nice BDD cycle, too. You can start the story like
> this:
>
> When I enter the following values into the contact us form
> | Name | Email | Message |
> | x | y@z | test m |
> Then I should be sent to the contact us confirmation page
> And an email should be sent to '...@
z.com' saying 'Thanks!'