Slides for my talk at General Assembly's Web Dev bootcamp. Covers the motivations behind software testing, some theoretical background and hands-on exercises. Final challenge is testing a real-world like Node.js API using Mocha & Chai.
3. Why?
● Working software
● Intended functionality
● No bugs
● No downtimes
● No security issues
● Extensible, easy to extend & modify
(because we need to pivot)
19. Good tests are:
● Fast - milliseconds!
● Small - test only a single piece of functionality at a time
● Simple - complexity = less reliability
● Plentiful - several tests per feature
● Isolated - have no dependencies between each other
● Readable - other people will need to read them too
● Clean - same code quality as the software they are testing
20. TDD/BDD
The two rules of TDD:
● Don’t write a single line of code unless you have a failing automated test
● Eliminate duplication
How to?
● Write a small test (and watch it fail)
● Make the test work (quick & dirty)
● Eliminate duplication (refactor)
Behaviour Driven Development (also ATDD):
● Similar to TDD for higher level tests
● Readable by Product Owners, Business Analysts, etc.
21. BDD
Feature: Listing command
In order to change the structure of the folder I am currently in
As a UNIX user
I need to be able see the currently available files and folders there
Scenario: Listing two files in a directory
Given I am in a directory "test"
And I have a file named "foo"
And I have a file named "bar"
When I run "ls"
Then I should get:
"""
bar
foo
"""
http://docs.behat.org/en/v3.0/ (PHP)
https://cucumber.io/ (Rails)