Test - GateKeepers of our code

  • we write a lot of code:
  • we want to add a new feature -> we write code. How do we know it works?
  • We want to fix a bug -> we write code. How do we know we didn't break anything?
  • We want to refactor - we write code. How do we know we didn't break anything?
  • As the company grows -> we have even more code

How do we deal with all that code?

Naive answer is QA people.

  • Human Errors
  • Expensive - Human resources
  • Not ​repetitive 
  • Slow - not agile

Tests to the ​rescue!

What are Tests?

Test is code that checks that the code that you write in your app, also called “production code”, works as expected

Purpose of tests

  • finding bugs
  • verify the code does what the product describes 
  • verify the product is fit for use

small test example?

it('should...')

Types of tests

  • unit tests
  • integration tests
  • e2e tests

Unit Tests

  • The smallest testable part of an application
  • Usually a method or a module
  • Each test case is independent from the others

example:

calculating cart total price

Integration Tests

  • Combine independently units 
  • Verify that the combined units works as expected

 

  • An integration test takes a small group of units, often two units, and tests their behavior as a whole, verifying that they coherently work together

example:

 

E2E Tests

  • Test that the complete flow of an application is performing as designed from start to finish
  • cover sections of the application that unit tests and integration tests don’t cover
  • TPA communication (Paypal)

example:

1. full purchase product with checkout

2. navigation

pyramid of tests

  • end-to-end tests do a better job of simulating real user scenarios
  • poor feedback loop

Tests VS Manual

Advantages 

  • Reliable
  • Fast (quick feedback)
  • Repetitive
  • An integral part of our development (we don't get the bugs after a couple of days)
  • Finding bugs in dev time and not on production
  • Clean code - only code that we need
  • clean code for our colleagues - we read more than we wrote (find stats)
  • documentation
  • easy to refactor

Disadvantages (?)

  • Lack of human input on stability and UI
  • Tests tools might have bugs
  • Tests might be flaky
  • Automation Environment and process might be expensive 
  • Might slow releasing features
  • Tests ​maintenance

Automation VS Manual

TDD

Agile

  • what is agile (philosophy)
  • TDD is one way of implementing agile (methodology)

Agile (as a discipline)

Agile

  • Approach to software development
  • Deliver quick and small parts of the app
  • Adjust well to Changing requirements
  • Creating an environment that fits those needs

History of Agile

First Computer - 1945

Turing writes​ code

  • invents subroutine
  • invents the stack
  • invents floating point
  • Etc.

1945

One of our difficulties will be the maintenance of an appropriate discipline

so that we do not lose track of what we are doing.

1945

1945

Number of computers 

in the world:

o(1)

1945

Number of programmers 

in the world:

o(1)

1950s

Programmers are drawn from:

  • Engineers
  • Scientists
  • Mathematicians

1965

Number of computers 

in the world:

o(1E4)

1965

Number of programmers 

in the world:

o(1E5)

1965

Not Enough:

  • Engineers
  • Scientists
  • Mathematicians
  • No CS Grads

Programmers drawn from:

  • Accountants, Planners, etc.

1970

  • Tens of thousands of new CS grads
  • very young
  • (almost most of them male)

TDD

Test Driven Development

  • software development process
  • Test first
  • Writing the minimal amount of code in order for the pass a failing test

TDD

  • Failing test
  • Passing test
  • Refactoring

Live Demo

deck

By danielagreen

deck

  • 384