CodeMash 2013 Day 3 Session 3

CodeMash

# Functional Testing with ASP.Net MVC
Jimmy Bogard

“If you’re writing unit tests for your controllers then you are wasting your time.”
“Ronald McDonald Screen” – an ASP.Net error page.
Unit tests don’t tell you that your application works.
Functional Tests – write tests as if your user were using the application.
Frees manual QA up for finding the edge cases – leave the computer to run the test scripts.
Selenium and WatiN are tools that automate your browser. Wrote NUnit tests to actually run the tests. Gallio can embed images in test reports and WatiN can take screenshots.
Do not use test recorders because they are extremely brittle.
The straightforward dumb UI test becomes very hard to maintain after time.

## Design for Testability
Because you own the application you can make changes to make it more testable.
Get your browser automation tool out pf your unit tests.
WatiN is COM based and requires STA (single apartment thread) attributes around it. If you don’t like it (and I think you should not like it) use Selenium instead.
You can use “rel” tags to define what you are controlling instead of the actual text or “id” attributes – less brittle.
Black box tests know nothing about your system. They are harder to use and maintain, so avoid them. It is OK for your tests to know how your application works.
It is OK to have your tests know about view models and strongly typed views. That’s how you keep them from being brittle – the shared knowledge.

Advertisements