Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Who will Test your tests!

Priti
August 11, 2015

Who will Test your tests!

This is the talk given at first XP conf, Bangalore (http://xpconference.in/) by me and Yahya Poonawala (https://www.linkedin.com/in/yahyapoonawala).

We all know advantages of writing tests, but when it becomes unmaintainable and we get into a situation, where we start hating our test suite, this is talk for those people who are plagued with disease of flakiness!

Priti

August 11, 2015
Tweet

More Decks by Priti

Other Decks in Technology

Transcript

  1. TESTS Code works Reduce Bugs Reduce cost of change Allow

    Refactoring Faster development Reduce fear 3
  2. 9

  3. 1 7

  4. 1 9

  5. 2 2

  6. 2 3

  7. Thread 1::! if( name is not Yahya ) {! …!

    fputs( name, file )! …! }! ! Thread 2::! Initialize name to Yahya! !
  8. Initialize lock;! ! Thread 1::! Acquire lock! if( name is

    not Yahya) {! . . . ! fputs( name, file )! . . .! }! Release lock! ! Thread 2::! Acquire lock! Initialize name to Yahya! Release lock! ! !
  9. ! ! make asynchronous call;! ! While (response received?)! if

    timeout then ! throw Test Timeout Exception ! ! else! sleep(10)! . . . ! ! read response! ! !
  10. # //pseudo-code! FILE_NAME = “content.txt”! ! // Test 1:! !

    FileReader.read(FILE_NAME).to be empty! ! // Test2: Write to the file! ! data = “Priti”! FileWriter.write(FILE_NAME, data)! FileReader.read(FILE_NAME) == data! ! // Test 3: Updates the file! ! append_data = “Biyani”! complete_data = “Priti Biyani”! FileWrite.append(FILE_NAME, append_data)! FileReader.read(FILE_NAME) == complete_data! !
  11. 4 0

  12. There is no such thing as FLAKY TEST! If its

    flaky, its not a test ! 4 8
  13. REFERENCES •  An Empirical Analysis of Flaky tests •  Eradicating

    Non-Determinism in Tests – Martin Fowler •  No more flaky tests on the GO team - Pavan Sudarshan •  Top 12 reasons to write unit tests •  http://tech.just-eat.com/2015/03/30/how-to- fix-flaky-tests/ 5 0