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

A matter of trust – Test

A matter of trust – Test

Our daily work at Shopware, but also at agencies, ends up in the hands of people who trust us not only to have done our best, but also that it works. It is our job to instill this trust. Fortunately, we developers have a way to ensure something like that: Testing! Let's discover in this talk how we approach automated testing in Shopware, how far we have come on this journey, and what we have gained so far.

36751965e79dca4618cccc3c08efc912?s=128

Ramona Schwering

June 19, 2020
Tweet

Transcript

  1. A matter of trust - Test

  2. Photo by Ankush Minda on Unsplash

  3. Photo by Luca Upper on Unsplash

  4. Photo by Bernard Hermant on Unsplash

  5. Testing @FloydThreepwood & @leichteckig

  6. Photo by freestocks on Unsplash

  7. Photo by Ferenc Almasi on Unsplash

  8. A test is a proof for your assumptions @FloydThreepwood &

    @leichteckig
  9. “Program testing can be used to show the presence of

    bugs, but never to show their absence! ” Edsger W. Dijkstra @FloydThreepwood & @leichteckig
  10. @FloydThreepwood & @leichteckig

  11. @FloydThreepwood & @leichteckig

  12. @FloydThreepwood & @leichteckig

  13. Service Tests @FloydThreepwood & @leichteckig

  14. Testing classes @FloydThreepwood & @leichteckig

  15. @FloydThreepwood & @leichteckig

  16. // Jest import 'src/module/sw-order/component/sw-order-user-card'; describe('modules/sw-order/component/sw-order-user-card/tracking-code-display', () => { const userCard

    = Shopware.Component.build('sw-order-user-card'); it('should render no url, when no base url is present in the shipping method', () => { expect( userCard.methods.renderTrackingUrl( 'TR-4CK1N-GCD', {trackingUrl: ''} ) ).toBe(''); }); }); @FloydThreepwood & @leichteckig
  17. @FloydThreepwood & @leichteckig

  18. Integration tests @FloydThreepwood & @leichteckig

  19. Testing a stack @FloydThreepwood & @leichteckig

  20. @FloydThreepwood & @leichteckig

  21. //phpUnit namespace Shopware\Core\Checkout\Test\Order; class UserOrderTest extends PHPUnit\Framework\TestCase { use IntegrationTestBehaviour;

    public function testOrderFromNewUser(): void { $this->fillUpCart(); $this->getContainer()->get(AccountService::class) ->register($newUserPayload); $this->getContainer()->get(CartService::class) ->order(); $this->assertNewUserOrderedSuccessfully(); } } @FloydThreepwood & @leichteckig
  22. @FloydThreepwood & @leichteckig

  23. End-to-end tests @FloydThreepwood & @leichteckig

  24. Real user workflows are simulated @FloydThreepwood & @leichteckig

  25. @FloydThreepwood & @leichteckig

  26. // Cypress describe('iphone-6 resolution', () => { // executed before

    each test beforeEach(() => { // run these tests as if in a mobile browser // and ensure our responsive UI is correct cy.viewport('iphone-6'); }); // actual test it('@navigation: Displays mobile menu on click', () => { cy.get('.nav.main-navigation-menu').should('not.be.visible'); cy.get('.header-main .menu-button .nav-main-toggle-btn').should('be.visible').click(); cy.get('.offcanvas.is-left.is-open').should('be.visible'); }); }); @FloydThreepwood & @leichteckig
  27. Photo by Pankaj Patel on Unsplash

  28. Achievement unlocked! @FloydThreepwood & @leichteckig

  29. Photo by Kevin Butz on Unsplash

  30. Photo by Dave Lowe on Unsplash

  31. Challenges to face ... @FloydThreepwood & @leichteckig

  32. Photo by Veri Ivanova on Unsplash

  33. Photo by Annie Spratt on Unsplash

  34. TL;DR @FloydThreepwood & @leichteckig

  35. Photo by SpaceX on Unsplash

  36. Thank you! @FloydThreepwood & @leichteckig