#2 Pencils Not Required
questions: @zachfedor
noun:
a procedure intended to establish the quality, performance, or reliability of something, especially before it is taken into widespread use.
make testing approachable
build a thing. be happy.
see if it worked.
it didn't.
be confused...
this is repetitive and time consuming.
tests handle the repetition for you.
get a new project. be happy.
build all the things.
look back at your work.
be confused...
code is complex.
tests help document it.
code grows over time.
tests help prevent growing pains.
even simple features have edge cases.
tests help cover all your bases.
manual tests make you build first.
tests help you design first.
Unit: make sure a small piece of code does it's one job well
Integration: make sure two pieces of code work together properly
Acceptance: make sure the user can do a task from start to finish
Examples
add(2, 3)
user.isLoggedIn()
$input.hasClass("error")
👌
👌
👌
5
true
false
Examples
form.submit()
$conn->query($sql)
<a onclick="myFunc(e)">
👌
👌
👌
http.response
true
MouseEvent
Examples
👌
👌
👌
A user can create an account
A user can filter a list of products
A user can submit their order
Unit
Integration
Acceptance
Touchpoints
Variables
Code
Resources
Time
Complexity
// Every Unit Test Should...
Describe the thing you're testing {
say(what it should do);
define expected = result;
// by knowing what it should do
define actual = result;
// by doing the thing
compare(actual, expected);
}
// add.js
function add (x, y) {
return x + y;
}
// add.test.js
describe('add()', () => {
it('should take two numbers and return their sum', () => {
const actual = add(2, 3);
const expected = 5;
expect(actual).toBe(5);
);
});