Automated ui testing with Specflow and WaTiN

16
© 2012 Aviva Solutions 14-08-22 Automated Testing With SpecFlow and WaTiN Dennis Doomen dennis.doomen@avivasoluti ons.nl

description

Test Driven Development is a phenonemon every developer should be aware of by now. I can't believe I've been developing professionally without it, and have been using it in every project since I discovered it 5 years ago. But, applying TDD on UI logic can be challenging, even if you apply patterns like MVC, MVP or Presentation Model. Creating readable and maintainable unit tests that drive a Presentation, ViewModel or Controller is a big maintenance burden. That's why our ASP.NET WebForms/MVC project jumped on the SpecFlow and WaTiN bandwagon. Using this beautiful combination we can now smoke test the overall behavior of the system, in addition to the large coverage of automated unit tests. Granted, this isn't the same as Acceptance Test Driven Development, but those smoke tests have been really worth their money. The functional abstraction that SpecFlow offers has proven to be a valuable aspect that allows us to keep our UI tests maintainable. In fact, the Gherkin matra Given-When-Then has even found its way to our test professionals. During this talk, I'd like to share some of the basic principles behind SpecFlow and the most important aspects of WaTiN. Just like with TDD, there's a whole lot you can do wrong. That's why I want to focus on some of the best practices that worked for us. Anyway, if you're serious about building high quality products and system, check out what I have to share.

Transcript of Automated ui testing with Specflow and WaTiN

  • 1.Automated Testing With SpecFlow and WaTiNDennis Doomen 2012 Aviva [email protected] 30 augustus 2012

2. About Me Principal Consultant 15 years IT experience C++ origins but C# since 2001 Specialties .NET Architecture Scrum/XP ALM Speaker Public initiatives Silverlight Cookbook C# Coding Guidelines Fluent Assertions Internet www.dennisdoomen.net DZone MVB @ddoomen 2012 Aviva Solutions Dennis Doomen 30 augustus 2012 3. Challenges of UserInterfaceAutomation 2012 Aviva Solutions30 augustus 2012 4. Levels of UI Automation Stability Functional User WorkflowTechnical Activity 2012 Aviva Solutions 30 augustus 2012 5. Smoke Specification Tests Performance by ExampleTests Given a ninja has a third level black-belt When attacked by Chuck Norris Then the ninja should run for his life LivingBehavior Driven DocumentationDevelopment Characteristics Tests 2012 Aviva Solutions30 augustus 2012 6. ATDD combined with TDD Image from Growing Object-Oriented Software, Guided by Tests 2012 Aviva Solutions30 augustus 2012 7. Deep DiveDemo 2012 Aviva Solutions 30 augustus 2012 8. Stability Gherkin ScenariosFunctional Step DefinitionsUser Workflow WaTiN Technical Activity 2012 Aviva Solutions30 augustus 2012 9. Required SkillsScenariosCoding SkillsTesting Skills Step DefinitionsSupport Code WaTiN 2012 Aviva Solutions 30 augustus 2012 10. Features Represent functional slices Use Ubiquitous Language Name liked a book or chapter Organized by Epic User StoriesFeature: Hosting DinnersIn order to increase my business networkAs a entrepeneurI want to host dinners with interesting people from the community 2012 Aviva Solutions30 augustus 2012 11. Scenarios Key Examples of the Feature Stakeholder perspective UI agnostic != test scripts Manually executable Grammatically correctScenario: Attempting to host a dinner as a registered userGiven a registered userWhen you want to host a dinnerThen you should be able to schedule a dinner 2012 Aviva Solutions 30 augustus 2012 12. Steps Global over all features Dont combine Given = state When = actions Then = visible changeScenario: Attempting to host a dinner as a registered userGiven a registered userWhen you want to host a dinnerThen you should be able to schedule a dinner 2012 Aviva Solutions 30 augustus 2012 13. Step Definition Grouped by entities, entity groups or domain concepts Always use Page/Control pattern No private helper methods 2012 Aviva Solutions 30 augustus 2012 14. TablesScopedScenarioBindingsOutlines HooksAdvanced Topics TagsStep-ArgumentConversion Step Definitions Data SharingAssist Helpers 2012 Aviva Solutions30 augustus 2012 15. Reading Material Demo Code https://github.com/dennisdoomen/specflowdemo The Cucumber Book http://pragprog.com/book/hwcuc/the-cucumber-book The Secret Ninja Cucumber Scrolls http://cuke4ninja.com/toc.html Death by UI Test Automation http://gojko.net/2010/07/29/the-sine-of-death-by-ui-test-automation/ Code-to-Test Ratios, TDD and BDD http://www.infoq.com/articles/virtual-panel-tdd-bdd Growing Object-Oriented Software, Guided by Tests http://www.amazon.com/Growing-Object-Oriented-Software-Guided- Tests/dp/0321503627 2012 Aviva Solutions30 augustus 2012 16. Email [email protected] @ddoomen Blog www.dennisdoomen.net 2012 Aviva Solutions30 augustus 2012