Stable automation testing
Test-state pattern
maximk@wix.com
Wix automation
▪ 20 software engineers
in 4 different cities
▪ 3 teams, each responsible for
different projects
Lithuania
Ukraine
Vilnius
Kyiv
Dnipro
Wix Engineering Locations
Israel
Tel-Aviv
Be’er Sheva
Wix automation
▪ 20 software engineers
in 4 different cities
▪ 3 teams, each responsible for
different projects
▪ Infrastructure for writing,
executing, analyzing and
managing Selenium-based tests
▪ Internal services and tools
for the R&D group
Lithuania
Ukraine
Vilnius
Kyiv
Dnipro
Wix Engineering Locations
Israel
Tel-Aviv
Be’er Sheva
Today
E2E
#1 The problem - more breaking points
#2 The solution
#3 A better solution
E2E tests
E2E tests
Writing a stable
test is difficult
and writing a new
stable test is even
more fragile.
E2E tests
Writing a stable
test is difficult
and writing a new
test is even more
fragile. Why?
E2E tests
Writing a stable
test is difficult
and writing a new
test is even more
fragile.
They can pass locally, but
fail remotely.
We try to avoid...
noise
(analysis becomes
difficult)
and that could lead to
unstable tests running in production
Release
@Test
@Test
@Test
@Test
#1 The problem - more breaking points
#2 The solution - @BetaTest
#3 A better solution
E2E tests
Split the tests into 2 “run” groups
Release
No Beta tests =
less coverage
@Test
@BetaTest
@Test
@BetaTestBeta
@BetaTest (owner = "tzipi")
public void newTest() {
…
}
Beta run group reports results to server
Results
@Test
@BetaTestBeta
Release
Run groups in different
configurations
@BetaTest
Results
Beta
Release @Test
@Override
public void beforeTest(Description description) {
if (isBetaTestInReleaseRunMode(description) ||
isNonBetaTestInBetaRunMode(description)) {
TestUtils.ignoreTest();
}
}
@Test
Results
“Approve” stable beta tests
@BetaTestBeta
Release
How do we find the stable ones?
How do we find the stable ones?
Tests that pass X times in a row,
with maximum Y failures
Results
So, for each stable test
notify the owner
to replace @BetaTest
with @Test.
SERIOUSLY
???
So, for each stable test
notify the owner
to replace @BetaTest
with @Test.
#1 The problem - more breaking points
#2 The solution - @BetaTest
#3 A better solution - test state pattern
E2E tests
No need for a special @BetaTest annotation
@Test
Each test begins with a beta state
Beta
remains in beta state for some time
Beta
and (hopefully) changes to stable
Beta Stable
pass X times
@Override
public void beforeTest(Description description) {
TestState state = getTestState(description);
if (isBetaTestInReleaseRunMode(description, state) ||
isNonBetaTestInBetaRunMode(description, state)) {
TestUtils.ignoreTest();
}
}
what happens if a test keeps failing?
fail X
times
Beta
hall of shame - you manually fix those
fail X
times
Beta
Failed
Beta
manual
fix
what happens if a stable test starts to “act weird”?
Beta Stable
pass X times
we call it flaky
Beta
pass X times
Become
unstable
Stable
Flaky
pass X
times
what if it’s really stable?
Beta Stable
pass X times
we call that super stable
Beta
pass X times
always
passpass X times
Stable
Super
Stable
full state pattern
Beta
pass X times
fail X
times
manual
fix
Failed
Beta
Stable
Become
unstable
pass X
times
Flaky
always
pass
Super
Stable
Beta
Failed
Beta
Release
Flaky
stable automation is possible
Failed
Beta
Beta
Results
Release
Flaky
ALL report results to server
Implementing it in a project
Test Observer
- testStarted
- testIgnored
- testFailed
- testPassed
Java
Client
API Core Web
Web
View
Object Modeling
Test
- Name*
- State**
- Creation date
- Update date
- Annotations
Run Result
- Test Name
- Passed/Failed
- Creation date
- Configuration***
1 n
Thank You
Any Questions?
maximk@wix.com

QA Evening Максим Колотилкин - Test State Pattern