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

How to make tests more resilient

How to make tests more resilient

Talk about making rests more resilient.
Given on 1st of July 2020 at DWX Home: https://www.developer-week.de/dwx-home/#/talk/testen-vortrag-1-tba

Gregor Woiwode

July 01, 2020
Tweet

More Decks by Gregor Woiwode

Other Decks in Programming

Transcript

  1. 1

  2. 2

  3. date-fns const yesterday = subDays(new Date(), 1); const tomorrow =

    addDays(new Date(), 1); moment.js const yesterday = moment().subtract(1, 'days').toDate(); const tomorrow = moment().add(1, 'days').toDate();
  4. date-fns const yesterday = subDays(new Date(), 1); const tomorrow =

    addDays(new Date(), 1); moment.js const yesterday = moment().subtract(1, 'days').toDate(); const tomorrow = moment().add(1, 'days').toDate(); Library brand new Library
  5. export class TimeKeeper { get yesterday() { return moment().subtract(1, 'days').toDate();

    } get tomorrow() { return moment().add(1, 'days').toDate(); } } moment.js
  6. export class TimeKeeper { get yesterday() { return subDays(new Date(),

    1); } get tomorrow() { return addDays(new Date(), 1); } } date-fns
  7. 3

  8. export const primary = () "=> ({ "/* ""... "*/

    component: DataGridComponent, }); Specify you UI component
  9. export const primary = () "=> ({ "/* ""... "*/

    component: DataGridComponent, props: { displayedColumns: ['position', 'name', 'weight', 'symbol'], dataSource: new MatTableDataSource([ { position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H' }, { position: 2, name: 'Helium', weight: 4.0026, symbol: 'He' }, { position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li' } ]), }, }); Provide some test data
  10. describe('common-ui', () "=> { beforeEach(() "=> cy.visit('/iframe.html?id=datagridcomponent"--primary')); it('should sort by

    number', () "=> { cy.get('[data-testid=data-grid"__header"--number]').click(); cy.get('[data-testid=data-grid"__header"--number]').click(); cy.get('[data-testid=data-grid"__header"--number-value]') .first() .should('contain', 10); }); }); Write an UI test for your component
  11. Isolated UI Benefits Lower complexity of UI tests Focus on

    specific UI parts Get rid of side effects that break tests
  12. Summary Clarified the why of test stability Learned about test

    resiliency process Adapter pattern stabilises Unit Tests Isolated UI Tests stabilise e2e Tests
  13. Photo by Alex Wigan on Unsplash Photo by Chris Montgomery

    on Unsplash Photo by Bruno Martins on Unsplash Photo by Luke Stackpoole on Unsplash Photo by Steve Johnson on Unsplash Photo by Sigmund on Unsplash Image sources Photo by David Boca on Unsplash