Upload
ben-hall
View
633
Download
4
Tags:
Embed Size (px)
DESCRIPTION
Presentation for NxtGenUG Southampton on Thursday, August 20, 2009 on how to test ASP.net web applications
Citation preview
TESTING ASP.NET WEB APPLICATIONS
Twitter - @[email protected]
Based on the book “Testing ASP.NET Web Applications “
By Jeff McWherter, Ben HallISBN-10: 0470496649
ISBN-13: 978-0470496640Publisher: John Wiley & Sons (12 Nov 2009)
http://www.amazon.co.uk/Testing-ASP-NET-Applications-Jeff-McWherter/dp/0470496649
TONIGHT
• Test Driven Development (TDD)• Integration Testing• UI Testing• Acceptance Testing• Q\A
TEST DRIVEN DEVELOPMENT
TDD is not about testing!
Tests are a useful by-product
TDD helps you think about design
Take a step back and think!
Loosely coupled system
http://www.flickr.com/photos/clarkk/38817024/
Support debugging
Documentation for your code
/* * Every time I re-visit this function, I feel like * I need to take a shower. * * Don't get too used to this function, its days * are numbered.
*/
http://stackoverflow.com/questions/184618/what-is-the-best-comment-in-source-code-you-have-ever-encountered
Support refactoring
If it hurts – think!
It’s all about the mindset
Test Code 101
[TestFixture]public class ObjectUnderTestTests{ [Test] public void
MethodUnderTest_State_ExpectedBehaviour(){ string result = Convert.ToString(true); Assert.IsTrue(result);}
}
NUnit Attribute – Class contains tests
NUnit Attribute – This is a test
Disclaimer: This was a Hello World Linq to SQL example. Not a recommendation.
TDD + ASP.net WebForms
DEMO
TDD + ASP.net MVC
DEMO
RememberIt’s all about the mindset
INTEGRATION TESTING
Removing the stubs
Handling ASP.net
DEMO
Handling databases
DEMO
Handling external services
DEMO
http://www.flickr.com/photos/gagilas/2659695352/
LEGACY TESTING
UI TESTING
IETester
IETester
Browsershots
Opera 8.54 / Windows XP
Adobe Browser Lab
http://www.flickr.com/photos/gagilas/2659695352/
RECORD AND PLAYBACK
Automated UI Testing - WatiN
DEMO
WatiN + jQuery + Ajax
DEMO
UI tests are not without their problems
ACCEPTANCE TESTING
The customer is always right
Have them involved in the testing process
FitNesse
Behaviour Driven Development - BDD
Cucumber + Watir
DEMO
http://www.flickr.com/photos/leon_homan/2856628778/
Summary
Lots more we could discuss
Most of which is covered in the book
Need to try it for yourself to see true benefits
Tomorrow: Write one method using TDD and one UI test
Based on the book “Testing ASP.NET Web Applications “
By Jeff McWherter, Ben HallISBN-10: 0470496649
ISBN-13: 978-0470496640Publisher: John Wiley & Sons (12 Nov 2009)
http://www.amazon.co.uk/Testing-ASP-NET-Applications-Jeff-McWherter/dp/0470496649