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

Developing an Ember Test Strategy - EmberConf 2019

Developing an Ember Test Strategy - EmberConf 2019

Taking lessons from the classic writings on Software Testing, we'll walk through what are industry tried and true approaches for developing a robust and effective test suite.

Many of the Testing philosophies and strategies today have their origins as far back as the 60's, and really got their legs during the advent of "Extreme Programming" and other early "Agile" methodologies from the 1990s.

In this talk we'll take many of these tried and true test strategies and show how one would apply them in a real way to an Ember project.

Avatar for Todd Jordan

Todd Jordan

March 19, 2019
Tweet

More Decks by Todd Jordan

Other Decks in Programming

Transcript

  1. Boehm’s Law 0 $ $$ $$$ Requirments Design Development Test

    Prod https://docs.google.com/viewer?url=https%3A%2F%2Fwww.cs.umd.edu%2Fprojects%2FSoftEng%2FESEG%2Fpapers%2F82.78.pdf
  2. Test Types What Tests to Write and When to Use

    Them https://www.flickr.com/photos/chiffheed/6889521843
  3. Business Facing Technology Facing Support Programming Critique Product Performance Security

    Usability Exploratory Acceptance End To End Rendering Unit http://www.exampler.com/old-blog/2003/08/21.1.html#agile-testing-project-1 https://www.amazon.com/Agile-Testing-Practical-Guide-Testers/dp/0321534468
  4. Business Facing Technology Facing Support Programming Critique Product Performance Security

    Usability Exploratory Acceptance End To End Rendering Unit http://www.exampler.com/old-blog/2003/08/21.1.html#agile-testing-project-1 https://www.amazon.com/Agile-Testing-Practical-Guide-Testers/dp/0321534468
  5. Ember Testing Ember Unit Tests - Call functions directly (10-100ms)

    Ember Rendering Tests - Call components via the template compiler (200-600 ms) Ember Application Tests - Interact with the entire Ember application through the browser (700-3000ms with stubbed HTTP)
  6. 1000 Tests Unit Rendering Application Minutes 0 10 20 30

    40 33.3 6.7 1.7 Assumes 100ms Unit, 400ms Rendering, 2000ms Application
  7. 1000 tests: Distributed Minutes 0 3.5 7 10.5 14 33/33/33

    40/40/20 40/50/10 Unit Rendering Application
  8. “The original description of TDD was in an ancient book

    about programming. It said you take the input tape, manually type in the output tape you expect, then program until the actual output tape matches the expected output. ” -Kent Beck: OG Extreme Programmer, TDD Rediscoverer
  9. Classic TDD Test Your object tree forms as part of

    your refactor step Test API https://www.amazon.com/Test-Driven-Development-Kent-Beck/dp/0321146530
  10. Example in Ember: A Page Component Last Email Submit First

    Input: Object with First, Last, Email, Profile Pic Input: Save action Output: Rendered DOM Output: Action invoked Upload
  11. TDD with Mock Objects Mocks assert the behavior of your

    object’s collaborators Enable a form of “Need Driven Development” See sinon.js and ember- sinon https://www.amazon.com/Growing-Object-Oriented-Software-Guided-Tests/dp/0321503627 https://docs.google.com/viewer?url=http%3A%2F%2Fjmock.org%2Foopsla2004.pdf
  12. TDD with Mocks http://www.natpryce.com/articles/000342.html Test Mock Mock API Test Your

    mocks become the APIs for your next test Mocks are your roles
  13. TDD with Mocks http://www.natpryce.com/articles/000342.html Test Mock Mock API Test Your

    mocks become the APIs for your next test Keep going until you reach a “leaf”, or an external boundary Mocks are your roles
  14. Example in Ember: Chat Service Hi! New phone, who dis?

    todd.jordan locks 1:00pm 1:05pm Fetches chat history Receives incoming messages in realtime Sends outgoing messages
  15. TDD with Mocks Test Chat Service API Realtime Service Receive

    Incoming Profile Service Fetch Profile Info History Service Past Chats
  16. TDD with Mocks Test Chat Service Test API Realtime Service

    Receive Incoming Profile Service Fetch Profile Info History Service Past Chats
  17. E2E Tests Mocks Core Logic Macro Outside In (Need Driven

    Development) Tests API Mocks UI Mocks Tests
  18. E2E Tests Mocks Core Logic Macro Outside In (Need Driven

    Development) Tests API Mocks Data UI Mocks Tests
  19. E2E Tests Mocks Core Logic Macro Outside In (Need Driven

    Development) Tests API Mocks Data API UI UI Mocks Tests
  20. E2E Tests Mocks Core Logic Macro Outside In (Need Driven

    Development) Tests API Mocks Data API UI UI Mocks Tests *Done Iteratively, feature by feature
  21. - Nat Pryce, co-author: JMock, GOOS “Mock objects are just

    a tool. They are one of many tools that you need to use when doing TDD. Like any tool, they are designed to help solve a set of problems in a specific context.” “So, instead of treating mock objects, or any other technique or tool, as an all-or-nothing "golden hammer", it's more helpful to understand where that tool fits into the broader picture of TDD practice.” https://groups.yahoo.com/neo/groups/testdrivendevelopment/conversations/messages/29686
  22. The Flawed Theory Behind Unit Testing Classical TDD Mockist TDD

    Clean Room Design By Contract Michael Feathers https://michaelfeathers.typepad.com/michael_feathers_blog/2008/06/the-flawed-theo.html
  23. The Flawed Theory Behind Unit Testing Classical TDD Mockist TDD

    Clean Room Design By Contract Michael Feathers https://michaelfeathers.typepad.com/michael_feathers_blog/2008/06/the-flawed-theo.html All
  24. –Michael Feathers “Quality is a function of thought and reflection

    - precise thought and reflection. That’s the magic. Techniques which reinforce that discipline invariably increase quality.”
  25. Keep an eye on your feedback loops Test in a

    methodical way that drives design Thought and discipline are faster than quickly spitting out code