Something that is untested is broken.
Helps you write cleaner code
Helps document code
describe("Hello World", function() {
it("should say 'Hello, World!' when ran", function() {
expect(code.helloWorld()).to.equal("Hello, World!");
});
});Does this not tell you exactly what the code is expected to do?
Isn't that kind of what docs do?
Helps you get a job
Helps you sleep at night
Something that is untested is broken.
"Assert" & "Expect"
Makes sense to engineers
Write test code first. THEN the problem-solving code.
Does the code work?
"Should"
Makes sense to whole team
Does the code do what it's supposed to?
Discuss needed behavior with other stakeholders.
"Should"
"Assert" & "Expect"
Makes sense to engineers
Makes sense to whole team
Write test code first. THEN the problem-solving code.
Does the code do what it's supposed to??
Discuss needed behavior with other stakeholders.
Does the code work?
Do these things need to be mutually exclusive?
80%
15%
5%
80%
15%
5%
Should be fast, isolated, and repeatable
Focuses on small pieces of code, typically functions
A strict, written contract that the piece of code must satisfy
Can be automated or manually run
Can and will use threads, access the database or do whatever is required to ensure that all of the code and the different environment changes will work correctly.
Focuses on units combined and tested as a group.
Verifies functional, performance, and reliability of features
Can be automated or manually run
Microsoft Typepad has 325 functional requirements.
User testing of functional requirements of program.
Does this application behave in expected ways?
webdriver.js is a great tool for functional testing
How much of the program's code is covered by tests?
"Whenever you are tempted to type something into a print statement or debugger expression, write it as a test instead"
-- Martin Fowler
Code coverage is collected by using a specialized tool to instrument the binaries to add tracing calls and run a full set of automated tests against the instrumented product.
While code coverage is a good metric of how much testing you are doing, it is not necessarily a good metric of how well you are testing your product
DISCLAIMER:
Why test your code?
Red: write the test, run it --> fail
Green: make it pass --> pass
Refactor: make it better
What does red, green, refactor mean?
TDD tests are mostly understood by engineers
BDD tests can be understood by most
What is the biggest difference between TDD and BDD?
Individual functions
What does a unit test test?
Groups of functions, i.e. route handlers
What does an integration test test?
What is the most widely accepted pyramid of testing?
80%
15%
5%
What is code coverage?
How much of your code is tested