developer testing

24
Developer Testing Code Quality and You

Upload: chris-wallace

Post on 24-Jun-2015

140 views

Category:

Technology


0 download

DESCRIPTION

Slides from a Lunchtime Tech-talk, I did regarding Unit, Integration, and Acceptance Testing TDD, BDD

TRANSCRIPT

Page 1: Developer Testing

Developer Testing

Code Quality and You

Page 2: Developer Testing

If it builds, ship it

• Was young and foolish• Talk to a BA? QA? Never!• Just focused on writing code – not on quality

code• Bugs and bugs, oh my!

Page 3: Developer Testing

In all fairness

• Was young and naïve• “It worked on my machine”• Still a start-up with a start-up mentality where

the “Wild west” was accepted • But still there had to be a better way…

Page 4: Developer Testing

Ta-da!

Page 5: Developer Testing

Unit Tests

• Focuses on the smallest testable part of an application

• Independent

Page 6: Developer Testing

Unit Testing

• Cheap!• Finds problems early• Facilitates changes• Promotes decoupling• Living Documentation

Page 7: Developer Testing

Example Unit Test

Page 8: Developer Testing

Integration Tests

• Verifies functional, performance, and reliability– Do all the individual “units” work together?– Do all the combined “units” work in a performant

manner?– Do all the “units” work with external resources

and/or dependencies?

Page 9: Developer Testing

Integration Test Example

Page 10: Developer Testing

Acceptance Tests

• Higher-level tests that verify completeness of a user story

• Written in Gherkin:Given that I’m Product Owner,When the sprint ends,Then all of the stories should meet my requirements

• Highly collaborative between customers, Product Owners, BAs, QAs and Devs

Page 11: Developer Testing

Acceptance Tests

• A user story is not considered complete until the acceptance tests have passed

Page 12: Developer Testing

Acceptance Test Example

Page 13: Developer Testing

UI & Manual Tests

• Harder to automate• Still need to do exploratory testing

Page 14: Developer Testing

But what about…

• Regression Testing?– Rerun all of the tests we created previously

• Smoke Testing?– Rerun a subset of the tests we created previously

• Performance Testing?– Rerun a focused subset of the tests we created

previously with concurrency and load against a benchmark

Page 15: Developer Testing

Composition of the Tests

• Happy Paths• Sad Paths• “Woah, wasn’t expecting that” Paths

Page 16: Developer Testing

Testing Anti-Patterns

• But aren’t code reviews a substitute?• But we are near the end of Project XYZ; why

should we add tests now?• But couldn’t we “break” the code by adding

tests?• But it will take a longer time to complete• But our code-base is too large/complex to add

tests

Page 17: Developer Testing

Test Driven Development (TDD)

• Write a Test that fails• Write some code• Make all Tests pass• Refactor• Rinse and Repeat

Page 18: Developer Testing

Behaviour Driven Development (BDD)

• Write a Test* that fails• Write some code• Make all Tests pass• Refactor• Rinse and Repeat

*With a different purpose in mind; acceptance

Page 19: Developer Testing

TDD v BDD

• If I am doing BDD then do I need to do TDD or vice versa?– Absolutely!– TDD makes sure you are writing the thing right;

BDD makes sure you are writing the right thing

Page 20: Developer Testing

What about Code Reviews?

• Absolutely!• But the first question needs to be “show me

the passing tests”• Make sure we are getting better at writing

tests

Page 21: Developer Testing

The Who

• Quality is everyone’s responsibility– Devs– QAs– BAs– UX– Product Owners

Page 22: Developer Testing

The When

• During each sprint:– BA, Dev & QA all collaborating and following each

story to completion

• Today!

Page 23: Developer Testing

Developer Testing

• “How do I sell my executive team on doing this stuff? Don't. Just do it. They don't know what you're doing anyway” —Jim Highsmith

Page 24: Developer Testing