the question is, what is the definition and opposition of unit tests, where is it coming from and what is the structure

From my own experience over many companies and teams over the years, most people who try to unit test their code either give up at some point or don’t actually perform unit tests. They waste a lot of time writing problematic tests and then give up when they have to waste a lot of time maintaining them or worse, not TRUSTING their results.

1 The basics of unit testing — The Art of Unit Testing, Third Edition MEAP V02

Think of the unit test suite as a parachute. How many holes do you want to have in your parachute?

— Robert C. Martin

1. the origins: (1970s), KENT BECK, smalltalk

  • in the 1970s, KENT BECK (TDD, Extreme Programming) created the idea of the UNIT TEST in Smalltalk

2. what is a unit ?

  • unit of WORK 🠊 system’s USE CASE containing
Image for post
Image for post
  • it can be single function, multiple functions, multiple modules

3. definition

  • A unit test is a piece of code that:
  1. invokes a unit of work
  • A unit test’s scope can span as little as a function or as much as multiple modules or components depending on how many functions and modules are used between the entry point and the exit point.

4. attributes

  • [x] fast

5. exit point types

5.1. direct-outputs: return values — query

  • return a useful value (not undefined)

5.2. indirect-outputs: state change — command

  • noticeable state-change

5.3. indirect-output: callout

  • test has no control over the callout

6. difference: integration tests

  • if the test uses the REAL network, the REAL rest APIs, REAL system time, the REAL filesystem, or a REAL database, it has stepped into the realm of INTEGRATION TESTING

7. sources

today I learnt… | as a support eng of the wonderful Snowplow Analytics, expect everything around modern (postmodern?) business intelligence

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store