wix automation - test state pattern - 11.9.16

38
Test State Pattern Roi Ashkenazi Elad Benitah [email protected] [email protected] WixAutomation

Upload: efratao

Post on 08-Apr-2017

201 views

Category:

Engineering


1 download

TRANSCRIPT

Page 1: Wix Automation - Test State Pattern - 11.9.16

Test State Pattern

Roi AshkenaziElad Benitah

[email protected]@wix.com

WixAutomation

Page 2: Wix Automation - Test State Pattern - 11.9.16
Page 3: Wix Automation - Test State Pattern - 11.9.16

01 / The Problem

Page 4: Wix Automation - Test State Pattern - 11.9.16

E2E tests have more breaking points.

Writing a stable E2E test is

difficult

Page 5: Wix Automation - Test State Pattern - 11.9.16

New E2E tests are even more fragile.

Why?

Page 6: Wix Automation - Test State Pattern - 11.9.16

Pass locally, fail remotely

●Timing issues●Remote connection issues●Bad luck

Page 7: Wix Automation - Test State Pattern - 11.9.16

We try to avoid …False positives Causes lack of trust

NoiseAnalysis becomes difficult

Shame

Page 8: Wix Automation - Test State Pattern - 11.9.16

@Test@Test

@Test

Release Unstable tests

running in production

Page 9: Wix Automation - Test State Pattern - 11.9.16

02 / Solution: @BetaTest

Page 10: Wix Automation - Test State Pattern - 11.9.16

@BetaTest@BetaTest

@BetaTest

Beta @Test

@Test

@Test

Release

Split the tests into 2 “run groups”

No Beta tests - Less coverage

Page 11: Wix Automation - Test State Pattern - 11.9.16

@BetaTest(owner = "tzipi")

public void newTest() {

}

Page 12: Wix Automation - Test State Pattern - 11.9.16

@BetaTest@BetaTest

@BetaTest

Beta @Test

@Test

@Test

Release

Results

Beta run group reports results to server

Page 13: Wix Automation - Test State Pattern - 11.9.16

@BetaTest@BetaTest

@BetaTest

Beta @Test

@Test

@Test

Release

Run groups in different configurations

Results

Run X times per night

Page 14: Wix Automation - Test State Pattern - 11.9.16

@Override

public void beforeTest(Description description) {

if (isBetaTestInReleaseRunMode(description) ||

isNonBetaTestInBetaRunMode(description)) { TestUtils.ignoreTest();

}

}

Page 15: Wix Automation - Test State Pattern - 11.9.16

@BetaTest@BetaTest

@BetaTest

Beta @Test

@Test

@Test

Release

“Approve” stable BetaTests

Results

Page 16: Wix Automation - Test State Pattern - 11.9.16

How do we find the stable ones?

Page 17: Wix Automation - Test State Pattern - 11.9.16

Results

Tests that pass X times in a row, with maximum Y failures.

How do we find the stable ones?

Page 18: Wix Automation - Test State Pattern - 11.9.16

So, for each stable test notify the owner to replace @BetaTest with @Test

Page 19: Wix Automation - Test State Pattern - 11.9.16
Page 20: Wix Automation - Test State Pattern - 11.9.16

03 / We Can Do Better

Page 21: Wix Automation - Test State Pattern - 11.9.16

@Test@Test

@Test

Beta @Test

@Test

@Test

Release

No need for special @BetaTest annotation

Results

Page 22: Wix Automation - Test State Pattern - 11.9.16

Beta

Each test begins with a Beta state

Page 23: Wix Automation - Test State Pattern - 11.9.16

Beta

Remains in Beta state for some time

Page 24: Wix Automation - Test State Pattern - 11.9.16

Beta

And (hopefully) changes to stable

Stable

pass X times

Page 25: Wix Automation - Test State Pattern - 11.9.16

@Override

public void beforeTest(Description description) {

TestState state = getTestState(description); if (isBetaTestInReleaseRunMode(description, state) ||

isNonBetaTestInBetaRunMode(description, state)) {

TestUtils.ignoreTest();

}

}

Run tests according to their state

Page 26: Wix Automation - Test State Pattern - 11.9.16

What happens if a test keeps failing?

Betafail X times

Page 27: Wix Automation - Test State Pattern - 11.9.16

What happens if a test keeps failing?

Beta

Failed

Beta

fail X times

Page 28: Wix Automation - Test State Pattern - 11.9.16

Failed beta - manual fix

Beta

Failed

Beta

fail X times

manual fix

Page 29: Wix Automation - Test State Pattern - 11.9.16

Beta

What happens if a stable test starts to “act weird”?

Stable

pass X times

Page 30: Wix Automation - Test State Pattern - 11.9.16

Beta Stable

FlakyFlaky

Become unstable

pass X times

pass X times

What happens if a stable test starts to “act weird”?

Page 31: Wix Automation - Test State Pattern - 11.9.16

Beta

Full pattern

Failed

Beta

fail X timesStabl

e

FlakyFlaky

Become unstable

pass X times

pass X times

manual fix

Page 32: Wix Automation - Test State Pattern - 11.9.16

Stable automation is possible!

Results

@Test@Test

@Test

Beta @Test

@Test

@Test

Release@Test

@Test

@Test

Flaky

Failed Beta

Page 33: Wix Automation - Test State Pattern - 11.9.16

04 / Architecture

Page 34: Wix Automation - Test State Pattern - 11.9.16

API Core Web DB

Web View

Java Client

Test Observer

- testStarted- testIgnored- testFailed- testPassed

Page 35: Wix Automation - Test State Pattern - 11.9.16

Test

- Name*- State**- Creation date- Update date- Annotations

Object modeling

Run Result

- Test Name- Passed / failed- Creation date- Configuration**

*

1 n

Page 36: Wix Automation - Test State Pattern - 11.9.16

05 / Live Demo

Page 37: Wix Automation - Test State Pattern - 11.9.16
Page 38: Wix Automation - Test State Pattern - 11.9.16

This is where you are going to present your final words.This slide is not meant to have a lot of text.Thank You!