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.
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
The two rules of TDD:
● Don’t write a single line of code unless you have a failing automated test
● Eliminate duplication
● 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.
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: