test automation 3

35
7 Years of Test Automation @mikeb2701

Upload: michael-barker

Post on 28-May-2015

205 views

Category:

Software


1 download

DESCRIPTION

Test Automation presentation for Auckland Software Craftmanship group

TRANSCRIPT

Page 1: Test automation 3

7 Years of Test Automation

!

@mikeb2701

Page 2: Test automation 3

Assumptions

• Testing is important

• Automating testing is important

Page 3: Test automation 3

Types of tests• Static Analysis

• Unit Testing

• Integration Testing

• Acceptance Testing!

• Performance Testing

• Testing in Live

• Exploratory Testing

Page 4: Test automation 3
Page 5: Test automation 3

The acceptance test suite as a whole both verifies that the application delivers the business value and guards against regressions or defects that break preexisting functions of the application.

— Humble, Farley, Continuous Delivery, 2010, Chapter 8.

Page 6: Test automation 3

An acceptance test may only drive and assert behaviour in the system through interfaces available to the system’s users.

Page 7: Test automation 3

Writing Acceptance Tests

Page 8: Test automation 3

@RunWith(AcceptanceTestRunner.class)@Multithreaded@AcceptanceTest(id = 29, flavour = {Flavour.PLACE_ORDER, Flavour.API})public class PlaceOrderAcceptanceTest extends DslTestCase {! @Before public void beforeEveryTest() {! adminAPI.createInstrument("name: instrument”, "orderQuantityIncrement: 0.1”,…); registrationAPI.createUser("user", "balance: 100000"); mtfMemberAPI.createMtfMemberAndFixSession("marketMaker"); publicAPI.login("user"); mtfFixAPI.login(“marketMaker"); } // end! @Test public void shouldRejectOrderIfNotLoggedIn() { publicAPI.logout(); publicAPI.placeOrder(“instrument", "side: buy", "quantity: 1.2”, "timeInForce: ImmediateOrCancel”, "unauthorised: true");!

Page 9: Test automation 3

@RunWith(AcceptanceTestRunner.class)@Multithreaded@AcceptanceTest(id = 29, flavour = {Flavour.PLACE_ORDER, Flavour.API})public class PlaceOrderAcceptanceTest extends DslTestCase {! @Before public void beforeEveryTest() {! adminAPI.createInstrument("name: instrument”, "orderQuantityIncrement: 0.1”,…); registrationAPI.createUser("user", "balance: 100000"); mtfMemberAPI.createMtfMemberAndFixSession("marketMaker"); publicAPI.login("user"); mtfFixAPI.login(“marketMaker"); } // end! @Test public void shouldRejectOrderIfNotLoggedIn() { publicAPI.logout(); publicAPI.placeOrder(“instrument", "side: buy", "quantity: 1.2”, "timeInForce: ImmediateOrCancel”, "unauthorised: true");!

Page 10: Test automation 3

@RunWith(AcceptanceTestRunner.class)@Multithreaded@AcceptanceTest(id = 29, flavour = {Flavour.PLACE_ORDER, Flavour.API})public class PlaceOrderAcceptanceTest extends DslTestCase {! @Before public void beforeEveryTest() {! adminAPI.createInstrument("name: instrument”, "orderQuantityIncrement: 0.1”,…); registrationAPI.createUser("user", "balance: 100000"); mtfMemberAPI.createMtfMemberAndFixSession("marketMaker"); publicAPI.login("user"); mtfFixAPI.login(“marketMaker"); } // end! @Test public void shouldRejectOrderIfNotLoggedIn() { publicAPI.logout(); publicAPI.placeOrder(“instrument", "side: buy", "quantity: 1.2”, "timeInForce: ImmediateOrCancel”, "unauthorised: true");!

Page 11: Test automation 3

@RunWith(AcceptanceTestRunner.class)@Multithreaded@AcceptanceTest(id = 29, flavour = {Flavour.PLACE_ORDER, Flavour.API})public class PlaceOrderAcceptanceTest extends DslTestCase {! @Before public void beforeEveryTest() {! adminAPI.createInstrument("name: instrument”, "orderQuantityIncrement: 0.1”,…); registrationAPI.createUser("user", "balance: 100000"); mtfMemberAPI.createMtfMemberAndFixSession("marketMaker"); publicAPI.login("user"); mtfFixAPI.login(“marketMaker"); } // end! @Test public void shouldRejectOrderIfNotLoggedIn() { publicAPI.logout(); publicAPI.placeOrder(“instrument", "side: buy", "quantity: 1.2”, "timeInForce: ImmediateOrCancel”, "unauthorised: true");!

Page 12: Test automation 3

@RunWith(AcceptanceTestRunner.class)@Multithreaded@AcceptanceTest(id = 29, flavour = {Flavour.PLACE_ORDER, Flavour.API})public class PlaceOrderAcceptanceTest extends DslTestCase {! @Before public void beforeEveryTest() {! adminAPI.createInstrument("name: instrument”, "orderQuantityIncrement: 0.1”,…); registrationAPI.createUser("user", "balance: 100000"); mtfMemberAPI.createMtfMemberAndFixSession("marketMaker"); publicAPI.login("user"); mtfFixAPI.login(“marketMaker"); } // end! @Test public void shouldRejectOrderIfNotLoggedIn() { publicAPI.logout(); publicAPI.placeOrder(“instrument", "side: buy", "quantity: 1.2”, "timeInForce: ImmediateOrCancel”, "unauthorised: true");!

Page 13: Test automation 3

DSL

PublicAPI

TradingUI

AdminAPI

Test

MtfMemberAPI

LoginPanelDriver

Selenium

BalancesPanelDriver

InstrumentPanelDriver

JavaAPIDriver

AdminAPIDriver

MtfFixDriver

XML/HTTP

QuickFIX

Drivers

Page 14: Test automation 3

Time Travel

Page 15: Test automation 3

ServiceService

ServiceService

Service

TimeMachine Test

Time Travel To

Time Delta Get CurrentTime

Page 16: Test automation 3

@RunWith(AcceptanceTestRunner.class)@AcceptanceTest(id = 5194, flavour = {Flavour.PLACE_ORDER, Flavour.API})@Multithreaded(tardis = true)public class CancelAndReplaceAcceptanceTest extends DslTestCase{ @Before public void setUp() { dsl.forceToUtcTimeZone(); dsl.enableTimeMachine();! dsl.createTimePoint("name: origin”, "value: <next weekday>"); dsl.createTimePoint("name: marketOpen", "value: origin plus 1 weekdayCalendarOpenOffset”);! dsl.waitUntil("marketOpen");

Page 17: Test automation 3

Pro-Tip:

Isolate as much as possible

Page 18: Test automation 3

Simple DSL

https://github.com/LMAX-Exchange/Simple-DSL

Page 19: Test automation 3

Acceptance Testing (Running)

Page 20: Test automation 3

RTAParallel

Sequential

Sequential

Sequential

RTA

RTA

RTA

Scotty RomeroServer

Jenkins

Page 21: Test automation 3
Page 22: Test automation 3
Page 23: Test automation 3

Intermittency

avp.wikia.com

Page 24: Test automation 3

Sources of Intermittency

• Bad code (under test)

• Bad test

• Environmental

Page 25: Test automation 3

Just Fix It!

Page 26: Test automation 3
Page 27: Test automation 3
Page 28: Test automation 3
Page 29: Test automation 3
Page 30: Test automation 3
Page 31: Test automation 3

Acceptance Test DB

Page 32: Test automation 3
Page 33: Test automation 3
Page 34: Test automation 3

Wrap-Up

•Write them well •Run them often •Keep them green

Page 35: Test automation 3

Thank you

Q&A