Typology - GradedJestRisk/test-training GitHub Wiki

Table of Contents

Fowler

Overview

Aka "Test pyramid"

Types

  • Unit
  • Integration
  • Acceptance
  • End to end (E2E)

Unit

Definition

Fowler on unit tests

List:

  • low-level, focusing on a small part of the software system
  • usually written these days by the programmers themselves
  • expected to be significantly faster than other kinds of tests
Unit:
  • OO design tends to treat a class
  • procedural or FP might consider a single function
  • a bunch of closely related classes
  • it's a situational thing - the team decides what makes sense

Styles

List:

  • mockist: solitary test (do NOT talk to real code when in test);
  • classic: social test (do NOT talk to real code when in test).
"We write the tests assuming everything other than that unit is working correctly, unless communicating with the collaborators was awkward (such as a remote credit card verification system)." => Classic

Fowler on unit test style

= Integration =

Fowler on integration tests

Involve test double. If external services are involved, consider adding Contract tests to ensure the test double has the same behaviour as the external service.

OCTO

Source here:

Overview:

  • unit
  • component
  • contract
  • integration
  • end to end
  • functional / acceptance

Unit

Schema here

Test component, mocking collaborators - exclude component with annotation / glue / conf => don't assert external calls, test BR

  • Mockito (no Spring ?)

component

Schema here

Test component boundary, still with no real collaborators (crossroad on unit & integration) - validate glue and config:

  • in-memory DB for repo
  • HTTP (not using network)
    • out: Wiremock for client
    • in: WebMvcTest for controller
  • Spring: use SpringBootTest with classes names

contract (WS)

Schema here Check consumer/producer contact (eg. openAPi contract) in semi-isolation (use stub)

  • Spring Cloud Contract verifier
  • PACT

Integration

Schema here

Check component communicate with REAL collaborators (do not check parameter or results, check that collaborator has ben called)

  • Spring runner, @SpringBootTest with no class

end to end

Schema here

Integration between ALL components: assert wiring, not BR

  • GUI: selenium
  • API: rest-assure

functional test (acceptance)

Schema here

Smoke test on happy path => build confidence so business know BR regression testing is done in unit tests

  • cucumber
⚠️ **GitHub.com Fallback** ⚠️