50
TESTING ASP.NET WEB APPLICATIONS Twitter - @Ben_Hall Blog.BenHall.me.uk [email protected]

Testing ASP.net Web Applications

Embed Size (px)

DESCRIPTION

Presentation for NxtGenUG Southampton on Thursday, August 20, 2009 on how to test ASP.net web applications

Citation preview

Page 1: Testing ASP.net Web Applications

TESTING ASP.NET WEB APPLICATIONS

Twitter - @[email protected]

Page 2: Testing ASP.net Web Applications

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

Page 3: Testing ASP.net Web Applications

TONIGHT

• Test Driven Development (TDD)• Integration Testing• UI Testing• Acceptance Testing• Q\A

Page 4: Testing ASP.net Web Applications

TEST DRIVEN DEVELOPMENT

Page 5: Testing ASP.net Web Applications

TDD is not about testing!

Tests are a useful by-product

Page 6: Testing ASP.net Web Applications

TDD helps you think about design

Take a step back and think!

Page 7: Testing ASP.net Web Applications

Loosely coupled system

Page 8: Testing ASP.net Web Applications

http://www.flickr.com/photos/clarkk/38817024/

Page 9: Testing ASP.net Web Applications

Support debugging

Page 10: Testing ASP.net Web Applications

Documentation for your code

Page 11: Testing ASP.net Web Applications

/* * 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

Page 12: Testing ASP.net Web Applications

Support refactoring

Page 13: Testing ASP.net Web Applications

If it hurts – think!

Page 14: Testing ASP.net Web Applications

It’s all about the mindset

Page 15: Testing ASP.net Web Applications

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

Page 16: Testing ASP.net Web Applications

Disclaimer: This was a Hello World Linq to SQL example. Not a recommendation.

Page 17: Testing ASP.net Web Applications

TDD + ASP.net WebForms

DEMO

Page 18: Testing ASP.net Web Applications

TDD + ASP.net MVC

DEMO

Page 19: Testing ASP.net Web Applications

RememberIt’s all about the mindset

Page 20: Testing ASP.net Web Applications

INTEGRATION TESTING

Page 21: Testing ASP.net Web Applications

Removing the stubs

Page 22: Testing ASP.net Web Applications

Handling ASP.net

DEMO

Page 23: Testing ASP.net Web Applications

Handling databases

DEMO

Page 24: Testing ASP.net Web Applications

Handling external services

DEMO

Page 25: Testing ASP.net Web Applications

http://www.flickr.com/photos/gagilas/2659695352/

LEGACY TESTING

Page 26: Testing ASP.net Web Applications

UI TESTING

Page 27: Testing ASP.net Web Applications

IETester

Page 28: Testing ASP.net Web Applications

IETester

Page 29: Testing ASP.net Web Applications

Browsershots

Page 30: Testing ASP.net Web Applications

Opera 8.54 / Windows XP

Page 31: Testing ASP.net Web Applications

Adobe Browser Lab

Page 32: Testing ASP.net Web Applications

http://www.flickr.com/photos/gagilas/2659695352/

RECORD AND PLAYBACK

Page 33: Testing ASP.net Web Applications

Automated UI Testing - WatiN

DEMO

Page 34: Testing ASP.net Web Applications

WatiN + jQuery + Ajax

DEMO

Page 35: Testing ASP.net Web Applications

UI tests are not without their problems

Page 36: Testing ASP.net Web Applications

ACCEPTANCE TESTING

Page 37: Testing ASP.net Web Applications

The customer is always right

Page 38: Testing ASP.net Web Applications

Have them involved in the testing process

Page 39: Testing ASP.net Web Applications

FitNesse

Page 40: Testing ASP.net Web Applications
Page 41: Testing ASP.net Web Applications
Page 42: Testing ASP.net Web Applications
Page 43: Testing ASP.net Web Applications

Behaviour Driven Development - BDD

Page 44: Testing ASP.net Web Applications

Cucumber + Watir

DEMO

Page 45: Testing ASP.net Web Applications

http://www.flickr.com/photos/leon_homan/2856628778/

Summary

Page 46: Testing ASP.net Web Applications

Lots more we could discuss

Most of which is covered in the book

Page 47: Testing ASP.net Web Applications

Need to try it for yourself to see true benefits

Page 48: Testing ASP.net Web Applications

Tomorrow: Write one method using TDD and one UI test

Page 49: Testing ASP.net Web Applications

Thank you!

Twitter - @Ben_HallBlog.BenHall.me.uk

[email protected]

Page 50: Testing ASP.net Web Applications

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