Testa gränssnittet med BDD
Viktor Sarström, Evolve på nForum - 2017-11-23
Testning
“If It Ain’t Tested, It Ain’t Fixed”
Unit testing
Service testing
Integration testing
Application testing
Acceptance testing
UI testing
End-to-end testing
Performance testing
Exploratory testing
Regression testing
Smoke testing
Manual testing
12+
Teststrategier
Martin Fowler (Mike Cohn?), TestPyramid
https://martinfowler.com/bliki/TestPyramid.html
Alastair Scott, The-evolution-of-the-testing-pyramid
http://james-willett.com/2016/09/the-evolution-of-the-testing-pyramid/
James Wade, that testing pyramid
https://wade.be/development/2017/02/20/that-testing-pyramid.html
All models are wrong,
but some are useful.
George E. P. Box
BDD
Behavior-driven development
Gherkin
Business Readable, Domain Specific Language
Gherkin
● Beskriva ett beteendet utan att implementera det
● Dokumentation och test
● Finns på 60 språk
Some terse yet descriptive.feature
Gherkin
● Feature
● Scenario Given, When, Then, And, But (Steps)
● Background
● Scenario Outline
● Examples
Cucumber
”Business and IT don't always understand each other.”
Cucumber
● Verktyg för att köra tester skrivna i Gherkin
● “A single source of truth for everyone on the team.”
● Implementation finns i .NET (SpecFLOW), Java, PHP, JS, Ruby osv
Scribblewall
Verktyg
● Test runners
○ cucumber-js, Wallaby, Jest, Karma, SpecFlow ...
● Browser
○ Phantom, Zombie, Selenium, Headless chrome, Nightmare …
● Assertions
○ chai, sinon, shouldJS, Mocha
● Mockning
○ node-mock-server, node-api-server, nock …
● IDE
○ Visual studio 2017, Visual Studio Code, Atom, Eclipse ...
Verktyg
● Test runners
○ cucumber-js, Wallaby, Jest, Karma, SpecFlow ...
● Browser
○ Phantom, Zombie, Selenium, Headless chrome, Nightmare …
● Assertions
○ chai, sinon, shouldJS, Mocha
● Mockning
○ node-mock-server, node-api-server, nock …
● IDE
○ Visual studio 2017, Visual Studio Code, Atom, Eclipse ...
cucumber-js
test runner
Köra samma tester i både frontend och backend
/specs/Write on the scribblewall.feature
npm run test
/app/tests/step_definitions/Write on the scribblewall.js
zombie
browser
/app/tests/support/world.js
npm run test
/app/tests/step_definitions/Write on the scribblewall.js
npm run test
npm run test
/app/tests/step_definitions/Write on the scribblewall.js
/app/tests/step_definitions/Write on the scribblewall.js
npm run test
nock
mock
npm run test
HTML
JS
/app/tests/step_definitions/Write on the scribblewall.js
npm run test
/app/tests/step_definitions/Write on the scribblewall.js
npm run test
Slutsatser
● Ganska hög tröskel i början…
● … men värt det!
● Gränssnittstunga applikationer
● Logistiken från webben till kodbasen och vice versa är fortfarande knepig
● Skriva BDD-testerna är ett tungt jobb…
● … och bör inte göras av bara utvecklarna
Tack för mig!
Mail: viktor.sarstrom@evolvetechnology.se
Github: viktorlarsson
www.evolvetechnology.se

Test your user interface using BDD (Swedish)

Editor's Notes

  • #8 Automatiserade gui tester i toppen Några integrationstester Och några få enhetstester
  • #10 The focus really should be on where the risk lies in the software project, and then focusing the testing to address that risk for that project, regardless of whether that fits in with the pyramid or not.