Post on 09-Aug-2020
transcript
Why testers should know about TDD and how we can use it?
Raimond Sinivee, @RaimondSinivee
05.06.2015 @ntd2015
Agenda
• Terminology
• The Exercise
• The Problem
• The Story
• Unit testing and TDD
• The Testing Pyramid
• How testers could use TDD when they code software that helps in testing?
• The Exercise continues
@ntd2015, @RaimondSinivee
Terminology
1. Tools, scripts, harness, framework, helpers but not automation
2. There are no best practices, there are heuristics.
@ntd2015, @RaimondSinivee
Small example how TDD would look like in case of Selenium is the play• Download
• Java:• Source: http://1drv.ms/1RL14lp (3KB)
• Java libs: http://1drv.ms/1RKYsDO (26MB)
• Pyhton: App\python.exe src\SeleniumExample.py• Source http://1drv.ms/1RKYRX2 (1KB)
• Portable with Source http://1drv.ms/1RKYwU4 (37MB)
• Implement new method to SeleniumExample which would add to http protocol to a URL• Input “www.google.ee” returns http://www.google.ee
• Input “www.bing.com” returns http://www.bing.com
@ntd2015, @RaimondSinivee
Testing purpose code is first class citizen
• Regressions• Low first time quality
• Unknown state of code
• Problematic testing tools• Inaccurate
• Instable
• Not understandable code nor results
• Are your tests actually able to find the concern that they supposed to?
@ntd2015, @RaimondSinivee
Getting started
• Went to developer events, community gatherings, courses• CODE KATA
• Peer for troubleshooting
• Fix a bug
• Break down the wall
@ntd2015, @RaimondSinivee
@ntd2015, @RaimondSinivee
@ntd2015, @RaimondSinivee
@ntd2015, @RaimondSinivee
@ntd2015, @RaimondSinivee
Unit testing and Test Driven Development
• Unit test covers a single intent of a method
• TDD is a code design method• unit tests should be written before the code
• … but we have unit tests!• How would a development process look like when you write your tests before
the code or after the code?
• Don't test implementation, test intent
@ntd2015, @RaimondSinivee
The Test Pyramid
•Amount of tests
•Lines of Code
•Time to execute
•Time to understand failures
•Purpose
•Role@ntd2015, @RaimondSinivee
How testers could use TDD when they code software that helps in testing?• Developing testing tools
• Duplication
• Naming
• Troubleshooting• Debugging vs. unit testing
@ntd2015, @RaimondSinivee
What TDD gives to testers?
• Red – Green – Refactor mindset
• Testability: controllability and observability
• Fast feedback loop
• Do you practice what you talk about?
@ntd2015, @RaimondSinivee
Summary
• Red – Green – Refactor mindset
• Testability: controllability and observability
• Unit test before coding to test intent, remove duplication and improve naming
• Troubleshoot by writing unit tests
• @ntd2015, @RaimondSinivee
@ntd2015, @RaimondSinivee
Implementation ideas
• Add support for subdomain as input parameter to URL generation method in SeleniumExample• Input “www” returns http://www.google.de
• Input “” returns http://google.de
• Method to start specific driver.• IE, Chrome, Firefox, Safari
@ntd2015, @RaimondSinivee
Appendix
• Open Lecture by James Bach on Software Testing https://www.youtube.com/watch?v=ILkT_HV9DVU
• Test Pyramid: Initial idea author Mike Cohn, Succeeding with Agile: Software Development Using Scrum
• Book: Design Patterns: Elements of Reusable Object-Oriented Software, Gang of four.
• Is TDD dead: https://www.youtube.com/results?search_query=is+tdd+dead
• https://www.youtube.com/watch?v=vqwyMaHcjQE James Bach about testing agile process
• TDD for Testers What does TDD mean for me, the Tester?http://www.ministryoftesting.com/2014/08/tdd-testers/
• Integration Tests Are a Scam http://www.infoq.com/presentations/integration-tests-scam
• 7 Popular Unit Test Naming Conventions http://java.dzone.com/articles/7-popular-unit-test-naming
@ntd2015, @RaimondSinivee