Skip to content

Instantly share code, notes, and snippets.

@emilyfreeman
Last active December 6, 2015 18:36
Show Gist options
  • Save emilyfreeman/970f41008ae865b121cb to your computer and use it in GitHub Desktop.
Save emilyfreeman/970f41008ae865b121cb to your computer and use it in GitHub Desktop.

Abstract

Tests should work for you, not against you. Teams that hate testing don't test. But tests can make you a better programmer. They're like silent pair partners, guiding you to write the best code.

Your success at testing relies heavily on your approach and design. This talk will cover different approaches to testing, the great debate over end-to-end tests vs. unit tests and tools for testing your app. After which you'll be able to design tests that best serve your team.

Audience

Novice to intermediate-level developers interested in designing better, more reliable test suites for their applications.

Outline

The Great Debate: End-to-End Testing

Pros:

  • Shows individual pieces of code work in collaboration
  • Takes pressure off developers to write full-coverage unit tests
  • Focuses on user experience
  • Verifies real-world scenarios
  • Reduces the chance of missing a bug
  • May be resilient to sweeping code changes (depending on how high-level the test is)

Cons:

  • Slow to run due to dependencies (require browser/server)
  • Misses small bugs hidden under larger issues
  • Determining root cause of failing UI tests is difficult and time-consuming
  • Relies too heavily on external tools
  • Undermines reliability of automated tests
  • Encourages QA and developers to manually test the UI
  • Little to no feedback on code design

Different Approaches To Testing

Brief Overview of Test Pyramid Methodologies

3 Levels of Tests

  • The methodologies above emphasize 3 types of tests: end-to-end, integration and unit

End-to-End Tests

  • Verifies real-world scenarios, fully integrating the user interface

Integration Tests

  • Tests multiple layers of functionality without verifying user behavior

Unit Tests

  • Can cover most of your app’s functionality

Your Approach Will Depend On Your Team + Product

  • More complex code bases tend to benefit from an emphasis on comprehensive unit tests
  • Smaller code bases tend to do well with robust end-to-end tests

Not Sure Where To Start?

  • Minimize integration tests
  • Split tests into two categories: high-level end-to-end tests and low-level unit tests
    • High-level tests are resilient to code changes
    • Low-level tests give you fast, reliable feedback on your code
  • Add integration tests only as they're needed
  • Work with your team to determine testing standards

Overview of Testing

Best Practices

  • Keep logic out of UI
  • Avoid non-deterministic tests

Test Design

  • 3 parts: setup, action, assertion
  • Make your tests easy to read
  • Keep logic out of tests
  • Make it clear what's being tests
  • Keep test data minimal

Tools

Test Helpers
Unit Tests
  • Jasmine
  • QUnit
  • Mocha
Integration Tests
  • Capybara
  • Selenium
  • Phantom
  • Casper

Outcomes

  • Different approaches to testing
  • Finding the best fit for your team
  • Tools for different types of tests
  • Testing best practices

Pitch

Testing is hard. But great tests make great code.

This talk explores different approaches to testing and the reasoning behind each methodology. It dives deep into the debate over whether to emphasize end-to-end tests or unit tests. And it will help novice to intermediate developers better understand how to design reliable tests for their apps, empowering them to take ownership of their tests and go beyond "getting to green."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment