Wix Automation - The False Positive Paradox

25
1 Wix Automation The False Positive Paradox Efrat Attas

Transcript of Wix Automation - The False Positive Paradox

Page 1: Wix Automation - The False Positive Paradox

1

Wix AutomationThe False Positive Paradox

Efrat Attas

Page 2: Wix Automation - The False Positive Paradox

2

What?!What is “False Positive”?

Page 3: Wix Automation - The False Positive Paradox

3

What?!Release cycle

• Daily / Weekly deployments of multiple products• QA verifies each version using

manual and automation tests (accompanied by automation engineers)

Page 4: Wix Automation - The False Positive Paradox

4

What?!

Test failure not necessarily a bugFalse positives – What is it?

Page 5: Wix Automation - The False Positive Paradox

5

What?! Understand!False positives – What are the consequences?• Time consuming (in case of many

failures)• Bottleneck

Page 6: Wix Automation - The False Positive Paradox

6

Why?!Why is it happening?

Page 7: Wix Automation - The False Positive Paradox

7

Why?

• Unstable test – “flaky”• Outdated test

False positives – Why is it happening?

Page 8: Wix Automation - The False Positive Paradox

8

Why? Invent!Reduce false positives to a minimum• Identify • Isolate• Analyze• Fix the flakiness

Page 9: Wix Automation - The False Positive Paradox

9

How?!How to reduce outdated tests?

Page 10: Wix Automation - The False Positive Paradox

10

How?!

Bonus! Can also be used for “real” issues in product – true positives

Solution• Ignore On Bug annotation

Outdated test• Ignore test on bug with a link to Jira

issue

Motivation• Outdated test must be adapted to

new behavior without causing unnecessary failures during the refactor process

Page 11: Wix Automation - The False Positive Paradox

11

Solution

@IgnoreOnBug(issue = ”SE-5541”)@Test public void verifyButtonText() { … }

@IgnoreOnBug

Page 12: Wix Automation - The False Positive Paradox

12

Solution@IgnoreOnBug

@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface IgnoreOnBug {

String issue();

}

Page 13: Wix Automation - The False Positive Paradox

13

Solution@IgnoreOnBug

public interface TestObserver {

default void starting(Description description) { } default void before(Description description) { } default void ending() { } default void skipped(AssumptionViolatedException e, Description description) { }default void succeeded(Description description) { } default void failed(Throwable e, Description description) { } default void finished(Description description) { }

}

Page 14: Wix Automation - The False Positive Paradox

14

Solution@IgnoreOnBug

@Override public void before(Description description) { if(hasAnnotation(description, IgnoreOnBug.class)) {

String issue = getJiraIssueFromMethodAnnotation(description); if(!isJiraIssueSolved(issue)) {

ignoreTest(); } } }

Page 15: Wix Automation - The False Positive Paradox

15

How?!How to reduce unstable tests?

Page 16: Wix Automation - The False Positive Paradox

16

How?!Unstable test

* What is stable enough?

• New tests are executed independently, without affecting existing test results

Motivation• New test has to prove it is stable

enough* before entering the entire test collection

Solution• Beta test mechanism

Page 17: Wix Automation - The False Positive Paradox

17

Solution@BetaTest

• Beta tests will run in a specific configuration, X times every night• Each test will report its run result to a dedicated server• Beta tests which passed more than Y times will be

“approved”

Page 18: Wix Automation - The False Positive Paradox

18

Solution@BetaTest

@BetaTest(owner = "someone") public void verifyButtonText() { … }

Page 19: Wix Automation - The False Positive Paradox

19

Solution@BetaTest

@Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD, ElementType.TYPE}) public @interface BetaTest {

String owner();

}

Page 20: Wix Automation - The False Positive Paradox

20

Solution@BetaTest

Collection<Class<? extends Annotation>> testMethodAnnotations = Arrays.asList(Test.class, BetaTest.class);

@Override protected List<FrameworkMethod> computeTestMethods() {

return getAnnotatedMethods(getTestClass(), testMethodAnnotations); }

Page 21: Wix Automation - The False Positive Paradox

21

Solution@BetaTest

public interface TestObserver {default void starting(Description description) { } default void before(Description description) { } default void ending() { } default void skipped(AssumptionViolatedException e, Description description) { }default void succeeded(Description description) { } default void failed(Throwable e, Description description) { } default void finished(Description description) { }

}

Page 22: Wix Automation - The False Positive Paradox

22

Solution@BetaTest

@Override public void before(Description description) {

if (shouldIgnoreBetaTest(description)) {

ignoreTest("Test in beta mode - ignored"); }}

Page 23: Wix Automation - The False Positive Paradox

23

Solution@BetaTest

@Override public void succeeded(Description description) {

sendStatus(description, TestStatus.TEST_PASSED); }

@Override public void failed(Throwable e, Description description) {

sendStatus(description, TestStatus.TEST_FAILED); }

Page 24: Wix Automation - The False Positive Paradox

24

Solution@BetaTest

Page 25: Wix Automation - The False Positive Paradox

25

Thank you!Questions?