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.

Ramona Schwering

June 19, 2020
Tweet

More Decks by Ramona Schwering

Other Decks in Programming

Transcript

  1. “Program testing can be used to show the presence of

    bugs, but never to show their absence! ” Edsger W. Dijkstra @FloydThreepwood & @leichteckig
  2. // 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
  3. //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
  4. // 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