+ All Categories
Home > Software > Testing 101

Testing 101

Date post: 15-Apr-2017
Category:
Upload: manuel-de-la-pena-pena
View: 54 times
Download: 0 times
Share this document with a friend
54
TESTING I FIND YOUR LACK OF TESTS DISTURBING
Transcript
Page 1: Testing 101

TESTINGI FIND YOUR LACK OF TESTS

DISTURBING

Page 2: Testing 101

WHAT IS TESTING? YOU SAY WHILE YOU NAIL IN MY PUPIL YOUR PUPIL IN BLUE. WHAT IS TESTING? AND YOU ASK TO ME? TESTING… IS YOU.

To the unknown developer…

INTRO

Page 3: Testing 101

INTRO

1. The Dark Side

2. Padawan’s path

3. Use the Tests

4. Test practices

Page 4: Testing 101

THE DARK SIDE

Page 5: Testing 101

THE DARK SIDE

▸Companies

▸Want to reduce costs

▸Saving time -> reducing plans

▸Saving money -> reducing salaries

▸Developers

▸feel pressured and don’t have time to test

▸don’t want to test or to learn how to test

▸I’m not going to talk about salaries so let’s talk about technical things

Page 6: Testing 101

LIFECYCLE MANAGEMENT

Page 7: Testing 101

WATERFALLLIFECYCLE

Page 8: Testing 101

SOFTWARE LIFECYCLE MANAGEMENT

WATERFALL: A TRADITIONAL ENGINEERING APPROACHREQUIREMENTS

ANALYSIS

SOFTWARE DESIGN

IMPLEMENTATION

TESTING

INTEGRATION

DEPLOYMENT

MAINTENANCEhttps://en.wikipedia.org/wiki/Software_development_process

DOCUMENT IT !!

Page 9: Testing 101

V-MODELLIFECYCLE

Page 10: Testing 101

SOFTWARE LIFECYCLE MANAGEMENT

V-MODEL: AN EXTENDED WATERFALL

REQUIREMENTS ANALYSIS

SYSTEM DESIGN

IMPLEMENTATION

INTEGRATION

VALIDATION

MAINTENANCECONCEPTS OF OPERATIONS

INTEGRATION

VALIDATION

MAINTENANCE

TESTIN

G

UNIT

INTEGRATION

FUNCTIONAL

https://en.wikipedia.org/wiki/V-Model_(software_development)

TIMELINE

Page 11: Testing 101

SPIRALLIFECYCLE

Page 12: Testing 101

SOFTWARE LIFECYCLE MANAGEMENT

SPIRAL: CYCLES OF MINI-WATERFALLS

SOFTWARE DESIGN

CODE

TESTING

INTEGRATION

IMPLEMENTATION

OBJECTIVES RISKS

PLAN

https://en.wikipedia.org/wiki/Software_development_process

Page 13: Testing 101

AGILELIFECYCLE

Page 14: Testing 101

SOFTWARE LIFECYCLE MANAGEMENT

AGILE MANIFESTO

▸Based on 12 principles

▸ Individuals and interactions

▸Working Software

▸Customer collaboration

▸Responding to change

Page 15: Testing 101

SOFTWARE LIFECYCLE MANAGEMENT

AGILE MANIFESTO

▸Working software is the principal measure of progress

▸Welcome changing requirements, even in late development

▸Continuous attention to technical excellence and good design

Page 16: Testing 101

SOFTWARE LIFECYCLE MANAGEMENT

AGILE MANIFESTO

▸Working software: How do you assert that?

▸Changing requirements: How do you verify you don’t break existing things?

▸Good design: Are you able to easily test it?

Page 17: Testing 101

PADAWAN’S PATH

Page 18: Testing 101

PADAWAN’S PATH

▸Include Testing activities the soonest

▸Developers HAVE TO write tests

▸Do not treat QA as the next team in the line

Page 19: Testing 101

TEST EARLIER AND MORE

BEST PRACTICE 1

Page 20: Testing 101

PADAWAN’S PATH: WRITE TESTS EARLIER

▸Removes fear of changes

▸Executable examples/documentation

▸Enables refactoring

▸Helps you understand design

▸It’s not slower: faster and more robust

▸Visual feedback: red & green

Page 21: Testing 101

DEVELOPERS WRITE TESTS

BEST PRACTICE 2

Page 22: Testing 101

▸Unit, Integration and functional tests

▸Do not fall in the fallacy of automate everything: Automate critical things

▸This is not removing QA team: they automate things and specialise in Exploratory Testing

PADAWAN’S PATH: DEVELOPERS WRITE TESTS

Page 23: Testing 101

TREAT QA NOT AS “THE QA GUYS”

BEST PRACTICE 3

Page 24: Testing 101

http://sauceio.com/wp-content/uploads/2016/08/blog-post-600x451.png

Page 25: Testing 101

▸Otherwise, QA finds bugs when it’s expensive

▸QA are team members

▸Spread the knowledge with them: involve them in daily meetings, demos…

▸Result? Enables Exploratory Testing

PADAWAN’S PATH: THE IMPORTANCE OF QA TEAM

Page 26: Testing 101

USE THE TESTS

Page 27: Testing 101

UNITTEST TYPES

Page 28: Testing 101

UNIT TESTS

▸Isolated code

▸Executed fast

▸Always automated

▸I.e.: utility classes, POJO’s

▸Book: “Effective Unit Testing” Lasse Koskela

Page 29: Testing 101

UNIT TESTS: MOCKS

▸Mocks

▸Isolate code

▸Speed up test execution

▸Simulate special conditions

Page 30: Testing 101

UNIT TESTS: MOCKS

▸Stub: objects which return a specific value.

▸Fake Object: simpler than real implementation but more elaborated than a stub.

▸Spy Object: registers what is being executed in a test.

▸Mock: a more powerful spy object.

Page 31: Testing 101

UNIT TESTS: MOCKS

▸Mocks

▸Increase complexity/maintainability

▸Careful with wrong behaviour

▸Too much expectations

▸Corporate mocks

Page 32: Testing 101

INTEGRATIONTEST TYPES

Page 33: Testing 101

INTEGRATION TESTS

▸Code depending on other (module, component, service…)

▸Not executed that fast

▸I.e. database, file system, modules..

Page 34: Testing 101

END-TO-ENDTEST TYPES

Page 35: Testing 101

END-TO-END TESTS: PROS

▸Loved by management

▸Simulates user behaviour

▸Black-box testing

Page 36: Testing 101

END-TO-END TESTS: DRAWBACKS

▸Difficult root cause analysis

▸Small errors can hide real problems

▸Slow execution

▸Report bugs that could have been fixed before

▸Super hard maintenance

Page 37: Testing 101

MANUAL TESTS

UI TESTS

INTEGRATION

UNIT

Page 38: Testing 101

MANUAL TESTS

UI TESTS

INTEGRATION

UNIT70%

20%

10%

Page 39: Testing 101

SMOKETEST TYPES

Page 40: Testing 101

SMOKE TESTS

▸Define critical paths on your end-to-end tests

▸Execute it as a minimal proof of working software

▸Always automated

Page 41: Testing 101

EXPLORATORYTEST TYPES

Page 42: Testing 101

EXPLORATORY TESTING

▸You need knowledge of the system

▸Knowledge increases while you test

▸It’s not automated

▸Relay on human experience and knowledge

▸Use test methods

▸Book: “Explore it!” E.Hendrickson

Page 43: Testing 101

PERFORMANCETESTING TYPES

Page 44: Testing 101

PERFORMANCE

▸Stress or capacity testing

▸Physically separated machines

▸A typical configuration:

▸Injector, Database, Application, Console

▸Very hard or specialised

▸Periodically executed

▸Tools: jMeter, Grinder, LoadRunner

Page 45: Testing 101

OTHER TESTSTESTING TYPES

Page 46: Testing 101

OTHER TESTS

▸Behaviour (BDD)

▸Usability

▸Security

▸Comparison

▸Alpha/Beta

▸…

Page 47: Testing 101

TEST PRACTICES

Page 48: Testing 101

TEST PRACTICES

▸A @Test should have only one reason to fail

▸A @Test should check just one thing

▸A good commentary explains why, not what

Page 49: Testing 101

TEST PRACTICES

▸Avoid conditional logic in tests

▸A constantly falling @Test is useless

▸A @Test that cannot fail has no value (false sense of security)

▸A @Test promising more than it delivers is untrustworthy

Page 50: Testing 101

UNTRUSTWORTHY TESTS

// does not test anything

public void testFoo() {

MyStaticClass.foo();

}

// does not do anything

public void testFoo() {

//new MyClass().foo()

}

// promise much more than expected

public void testSendEmailAfterLogin() {

new MyClass().foo()

}

Page 51: Testing 101

TEST PRACTICES

▸Write platform independent tests

▸Flaky tests that fail intermittently as usually related to I/O

▸Do not hardcode test-dependencies

▸Delete/close resources in @Before/@After methods

Page 52: Testing 101

PREMATURE OPTIMISATION AND DUPLICATION ARE THE ROOT OF ALL EVIL

Lasse Koskela. “Effective Unit Testing”

TEST PRACTICES

Page 53: Testing 101

DUPLICATION IN TESTS COULD BE GOOD IN FAVOUR OF IMPROVED READABILITY

Lasse Koskela. “Effective Unit Testing”

TEST PRACTICES

Page 54: Testing 101

MAY THE TEST BE WITH YOU


Recommended