from 3 weeks to 30 minutes – a journey through the ups and downs of test automation

52
From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Upload: luyu

Post on 13-Jan-2016

17 views

Category:

Documents


0 download

DESCRIPTION

From 3 weeks to 30 minutes – a journey through the ups and downs of test automation. Who am I?. Peter Thomas Chief Software Engineer Operations IT, UBS Investment Bank Developer (mostly) I do some architecture I have done Testing I talk a lot (Mentor/ Coach) - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

From 3 weeks to 30 minutes – a journey through the ups and downs of test

automation

Page 2: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Who am I?

• Peter Thomas– Chief Software Engineer– Operations IT, UBS Investment Bank

• Developer (mostly)• I do some architecture• I have done Testing• I talk a lot (Mentor/Coach)

• From the dark side (consulting) but getting better

Page 3: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Where did we start?

• Existing mainframe legacy application• 3 week manual PPT testing cycle• 12 week delivery cycle

Page 4: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

What did we want to do?

• Belief there was a better way to deliver software

• Incremental development to deliver business value quickly

• Address the rapidly changing business landscape with flexibility in delivery

• Build quality into the solutions• Deliver the software rapidly, but in a cost

effective manner• Put the fun back into software delivery

Page 5: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

New York London Kiev Hyderabad Hong Kong

2M trades per day 100 billions settling per day in all major currencies50+ exchanges across EMEA and APAC15 scrum teams/120 people9 applicationsProduction releases every 2 weeks

Page 6: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

New York London Kiev Hyderabad Hong Kong

200 commits per day1000 artefacts updated per day1 commit every 5 minutes peak

Page 7: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

New York London Kiev Hyderabad Hong Kong

24 Build Targets60+ Test Targets800 Automated Functional Tests10, 000 Unit/Integration Tests7, 000 Behavioural Tests

Page 8: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

But……..

Page 9: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Our tests were…..

ComplicatedObscure

Random failuresSlow to run

Difficult to fix

Page 10: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

“The TDD rut”

ComplicatedObscure

Random failuresSlow to run

Difficult to fix

Page 11: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Test the Right Thing and

Test the Thing Right

When all you have is a hammer, everything looks like

a nail

Page 12: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Why do you test?

Page 13: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Why do you test?

• Because TDD tells me so?• Because (insert favourite method

here) says I should?• So I meet the 80% coverage metric?

Page 14: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Why do you test?

• To accept the solution• To understand and document the solution• To prove its not broken• To find the unknown unknowns• To help us design and build new features• To help us explore what is really needed• To show it won’t crash under load, to

show it is secure (to test the ‘ilities)…?

Page 15: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Why do you test?

Agile testing Quadrants – Lisa Crispin, Janet Gregory

Page 16: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Testing Purposefully

Page 17: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

The Right Thing At The Right Level

UnitComponent

System

Page 18: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

The Right Thing At The Right Level

UnitComponent

System

•Tests a single class with no dependencies•If dependencies like Spring Context, Database used then called Unit Integration•Tests technical correctness and robustness•Very specific, a failing test indicates an issue in a specific class•Difficult to perform on poor quality code•Very fast to run, should run on the developer’s desktop in the IDE

Page 19: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

The Right Thing At The Right Level

UnitComponent

System

•Tests a group of components which are integrated to perform a business relevant function•Can test technical or business correctness, but should be expressed in Domain concepts•Specific, a failing test indicates problems in that component•Easier to perform on poor quality code, provided component boundaries are clear•Can be quick to run, doesn’t need the full application, should run on developers desktop

Page 20: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

The Right Thing At The Right Level

UnitComponent

System

•Tests a system at its boundaries as a ‘black box’•Primarily testing for business correctness•Not Specific, a failing test could be caused anywhere in the system flow•Easy to perform on legacy applications, requires little code modification•Slow to run, can be fragile, may not run on developers desktop

Page 21: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

What We Wanted

Page 22: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

What We Had

Unit tests which weren’t really Unit TestsEnd to End tests when unit tests would have been sufficientDuplicate and redundant End to End tests

Page 23: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

The TDD Cycle

Page 24: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

TDD?@Test public void shouldBeEmtpyAfterCreation() {   ReportObject aTrm = new

ReportObject();  assertNull(aTrm.getEligibleTrm());   assertNull(aTrm.getProcessedEvent());

  assertNull(aTrm.getPayloadXml()); }

@Test public void shouldCorrectlySetAttributesViaConstructor() {   ReportObject aTrm = new ReportObject(eligibleObject, REPORTABLE_XML);   assertEquals(eligibleObject, reportableTrm.getEligibleTrm());   assertEquals(REPORTABLE_XML, reportableTrm.getPayloadXml()); }

@Test public void shouldCorrectlySetFieldsViaSetters() {   ReportObject aTrm = new ReportObject();  aTrm.setEligibleTrm(eligibleObject);   aTrm.setProcessedEvent(child);   aTrm.setPayloadXml(REPORTABLE_XML); 

assertEquals(eligibleObject, aTrm.getEligibleTrm());   assertEquals(child, aTrm.getProcessedEvent());   assertEquals(REPORTABLE_XML, aTrm.getPayloadXml()); }

Page 25: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

The Hollow Egg

Page 26: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

The Hollow Egg98 Tests2.5K LOC

30 Tests200 LOC

Page 27: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

RSpec model

Page 28: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Outside In - The TDD Spiral

Page 29: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Make the Intent Clear

How to achieve acceptance without showing your IDE or

log file to the users

Page 30: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Unit Test Naming?

testProcessError()

whenWorkItemIsManuallyAssignedThenClientRuleShouldBeSetToManualOverride()

shouldAllowAnActioningWorkItemToBeUpdated()

Page 31: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Test Data Nightmare

Page 32: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

What Do You Demo?

Page 33: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

What Do You Demo?

Page 34: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Executable Specification

Page 35: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Improve Testing Stability

Avoiding the Broken Windows syndrome

Page 36: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Separate Progress & Regression Tests

Page 37: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Speed-up Through Parallelism

Page 38: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Identify Unstable Tests

Page 39: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Quarantine Unstable Tests

Page 40: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Avoid External Dependencies

Page 41: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Introduce Fakes

Page 42: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Avoid Time-Dependent Tests

Page 43: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Test Isolation

Page 44: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Asynchronous Testing Headache

Page 45: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Don’t!

• Does your test need to be asynchronous?

• 80/20 rule?• Create synchronous test runner

harness

Page 46: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Asynchronous Testing using Events

Page 47: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

So…?

Page 48: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Treat your Tests Like you Treat your Code

“it’s just a test class” is not an excuse

Clean Code applies to tests too

Page 49: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Think about Why You are Testing

Specification tests for internal quality

Business tests for external quality

Page 50: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Think about Who You are Testing For

More people are interested in your tests than you may think

Page 51: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Zero Tolerance to Instability

“It runs OK on my machine” is not a valid response

Page 52: From 3 weeks to 30 minutes – a journey through the ups and downs of test automation

Interested in a career at [email protected]

@peterrhysthomaspeterrhysthomas.wordpress.com