strategic testing (codemash 2016)

52
STRATEGIC TESTING @DmitrySharkov

Upload: dmitry-sharkov

Post on 15-Apr-2017

172 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Strategic Testing (CodeMash 2016)

STRATEGIC TESTING@DmitrySharkov

Page 2: Strategic Testing (CodeMash 2016)

WHAT IS A TEST STRATEGY?

Page 3: Strategic Testing (CodeMash 2016)
Page 4: Strategic Testing (CodeMash 2016)
Page 5: Strategic Testing (CodeMash 2016)
Page 6: Strategic Testing (CodeMash 2016)
Page 7: Strategic Testing (CodeMash 2016)
Page 8: Strategic Testing (CodeMash 2016)

SYMPTOMS OF POOR TEST STRATEGY

Page 9: Strategic Testing (CodeMash 2016)

IT’S NOT NECESSARILY LOW QUALITY.

IT’S THE COST OF HIGH QUALITY.

Page 10: Strategic Testing (CodeMash 2016)

TEST SMARTER, NOT HARDER.

Page 11: Strategic Testing (CodeMash 2016)

test the right things

at the right time

with the right tools

Page 12: Strategic Testing (CodeMash 2016)

TESTING TOOLBOX — TYPES OF TESTS

•unit (small)• integration (medium)•end-to-end (large automated)•end-to-end (large manual)•unscripted/sapient•nonfunctional ("-ility") tests

Page 13: Strategic Testing (CodeMash 2016)

Test Type Sample TechnologiesUNIT JUnit, RSpec, NUnit, Spock, Mockito, Jasmine, Mocha

INTEGRATION same as above; custom

MANUAL E2E HP Quality Center, Gherkin, unstructured

AUTOMATED E2E HP Unified Functional Testing, Cucumber, custom

UNSCRIPTED unstructured

"ILITY" TESTS Gatling, sqlmap, Selenium Grid, WAVE

TESTING TOOLBOX — TECHNOLOGIES

Page 14: Strategic Testing (CodeMash 2016)

WE HAVE THE TOOLS. HOW DO WE USE THEM?

GOOD TEST STRATEGY

Page 15: Strategic Testing (CodeMash 2016)

• Minimizes waste.

• Puts burden of testing primarily on devs.

• Sustainable.

• Repeatable.

• Yields tests that maximize speed of feedback, reliability, and focus.

PROPERTIES OF A GOOD TEST STRATEGY

Page 16: Strategic Testing (CodeMash 2016)

• Favor tighter feedback loops.

• Think in terms of unknowns.

• Automate, automate, automate.

• Avoid redundancy.

• Don't be redundant.

• Address nonfunctional requirements early.

PRINCIPLES OF TEST STRATEGY (VERSION 0.3.4)

Page 17: Strategic Testing (CodeMash 2016)

Principle 1Favor tighter feedback loops.

Page 18: Strategic Testing (CodeMash 2016)

Principle 1Favor tighter feedback loops.

Cost

and

Run

tim

e

Test Type

lower order higher order

Page 19: Strategic Testing (CodeMash 2016)

Principle 1Favor tighter feedback loops.

Testing whether a seat belt locking mechanism works…

Page 20: Strategic Testing (CodeMash 2016)

Principle 2Think in terms of unknowns.

• unit tests? • service-level integration tests? • basic end-to-end automated tests? • testing Safari on iOS? • testing against production data?

What questions do you answer with…

Page 21: Strategic Testing (CodeMash 2016)

Principle 2Think in terms of unknowns.

• acceptance criteria — are they met? • architecture — is integration exercised? • environments — how is app affected? • non-functional reqs — are they met? • ??? (unknown unknowns)

What raises questions? (What are sources of unknowns?)

Page 22: Strategic Testing (CodeMash 2016)

Principle 3Automate, automate, automate.

Except for…

• Look and feel tests (maybe)

• Graphical consistency tests

• Wildly complex integrations

• Tests with risky side effects

• Stuff too hard to automate

Page 23: Strategic Testing (CodeMash 2016)

Principle 3Automate, automate, automate.

NO AUTOMATION FOR U

Page 24: Strategic Testing (CodeMash 2016)

Principle 4Avoid redundancy.

Across Test Levels

Across Platforms

Across Environments

Within Test Level

Page 25: Strategic Testing (CodeMash 2016)

Principle 4Avoid redundancy.

Track integration points.

ServiceController Data Store

? ?

Page 26: Strategic Testing (CodeMash 2016)

Principle 5Address nonfunctional

requirements early.

Page 27: Strategic Testing (CodeMash 2016)

Applying Strategy… Tactics!

Page 28: Strategic Testing (CodeMash 2016)

•Coverage of all acceptance criteria.

•Sufficient coverage of non-functional requirements.

•Fast combined run of tests. (Fast feedback loops.)

•Inexpensive (to write and maintain) test suite.

GOALS

Page 29: Strategic Testing (CodeMash 2016)

EXAMPLE: USER SEARCH

Page 30: Strategic Testing (CodeMash 2016)

Search by Last Name and (optionally) First Name.

Search is a case-insensitive "wildcard" search (uses terms as substrings).

Search is unavailable when offline.

Search button is disabled unless these search criteria are met: • If searching by Last Name only, at least 3 characters required. • If searching by both, at least 1 character required for each.

Search ignores non-alpha characters ([^A-Za-z]). This includes punctuation, numbers, and all "special" chars (á, ä, ñ etc.)

If a server-side error occurs, display sad emoji and error message. …

USER SEARCH — ACCEPTANCE CRITERIA

Page 31: Strategic Testing (CodeMash 2016)

Search by Last Name and (optionally) First Name. Search is a case-insensitive "wildcard" search (uses terms as substrings). Search is unavailable when offline. …

USER SEARCH — STORY 1

Start with a conversation about unknowns.

Page 32: Strategic Testing (CodeMash 2016)

STORY 1 — QUESTIONS TO ANSWER• Is the user able to enter search terms and press the search button?

• If results come back from the server, do they appear correctly?

• Do results return from the server successfully?

• Where do the results appear in the UI?

• Does the search service hit the data store correctly?

• Does the app search through the data correctly…

• …based on Last Name?

• …based on Last Name + First Name?

• Does the app return search results quickly enough?

Page 33: Strategic Testing (CodeMash 2016)

HOW DO WE ANSWER THESE?

Page 34: Strategic Testing (CodeMash 2016)

HOW DO WE ANSWER THESE?

Unit Tests• Is the user able to enter search terms and press the search button?

• If results come back from the server, do they appear correctly?

• Do results return from the server successfully?

• Where do the results appear in the UI?

• Does the search service hit the data store correctly?

• Does the app search through the data correctly…

• …based on Last Name?

• ….based on Last Name + First Name?

• Does the app return search results quickly enough?

Integration Tests

E2E Tests

Performance TestWhat can you isolate?

Page 35: Strategic Testing (CodeMash 2016)

SOME ANSWERS RAISE FURTHER QUESTIONS

• Does the app return search results quickly enough?

Performance Test

NOPEok then…

Page 36: Strategic Testing (CodeMash 2016)

SOME ANSWERS RAISE FURTHER QUESTIONS

• Does the search service leverage the cache properly?

New Integration Test

Service Data StoreCache

Page 37: Strategic Testing (CodeMash 2016)

USER SEARCH — NEXT STORY!Search by Last Name and (optionally) First Name. Search is a case-insensitive "wildcard" search (uses terms as substrings). Search is unavailable when offline. …

Oh! Oh! I know how to test it!

Page 38: Strategic Testing (CodeMash 2016)

Scenario Outline: user search Given I go to the user search page When I search for users by <first_name> and <last_name> Then I get back correct search results

Examples: | first_name | last_name | | Han | Solo | | *k* | Skywalker |

NO!

Page 39: Strategic Testing (CodeMash 2016)

Search is a case-insensitive "wildcard" search (uses terms as substrings).

What unknowns does this acceptance criterion raise?

Page 40: Strategic Testing (CodeMash 2016)

Consider components and integration points.

Search Service

Controller

Data Store

CacheWeb

Things

Web Voodoo

WHAT DO WE KNOW?

Does wildcard search introduce new ones?(Avoid redundancy.)

Page 41: Strategic Testing (CodeMash 2016)

STORY 2 — QUESTIONS TO ANSWER

• Does the search service handle wildcards correctly…

• …in the Last Name?

• …in the First Name?

• Does it pass the wildcard to the data layer properly?

Unit Tests

Integration Tests

Favor tight feedback loops!

Page 42: Strategic Testing (CodeMash 2016)

USER SEARCH — THIRD STORY!Search by Last Name and (optionally) First Name. Search is a case-insensitive "wildcard" search (uses terms as substrings). Search is unavailable when offline. …

Does the UI respond correctly if the server becomes unavailable?Does the UI respond correctly if the server becomes available?

Page 43: Strategic Testing (CodeMash 2016)

YOU DON'T NEED TO USE E2E TESTS HERE.

Simplify. Mock server responses. Inspect UI elements.

Page 44: Strategic Testing (CodeMash 2016)

SOME RULES OF THUMB (TACTICS)

• Logic you can isolate — unit tests• Validation• Display logic• Service logic• Boundary conditions

• Medium-sized collaboration — integration tests• Logic you cannot isolate — e2e tests

What are you testing?

Page 45: Strategic Testing (CodeMash 2016)

WHAT YOU SHOULD END UP WITH…

• Acceptance criteria covered.

• Unknowns minimized.

• A large unit test suite.

• A medium-sized integration test suite.

• A lean end-to-end test suite.

• Focused tests without redundancies.

Page 46: Strategic Testing (CodeMash 2016)

WHAT IT TAKES

Page 47: Strategic Testing (CodeMash 2016)

COMMON OBSTACLES

Lack of trust.

Page 48: Strategic Testing (CodeMash 2016)

COMMON OBSTACLES

Lack of common understanding.

Page 49: Strategic Testing (CodeMash 2016)

COMMON OBSTACLES

Working in silos.

Page 50: Strategic Testing (CodeMash 2016)

COMMON OBSTACLES

Lack of appropriate tools.

Page 51: Strategic Testing (CodeMash 2016)

BACK AT WORK…• Make a testing "pyramid" of current state.

• Put testers and implementers together

• Look for redundancy across test suites

• Move tests to as low a level as possible

• Look for signs that tests are missing

• Encourage knowledge transfer

• Start improving and never stop

Page 52: Strategic Testing (CodeMash 2016)

Thank you!@DmitrySharkov