liveBook · Manning

Synchronous testing

As explained in Effective Behavior-Driven Development

A testing pattern that runs an asynchronous operation synchronously when asynchrony is not the behavior under test.

Synchronous testing runs an asynchronous operation in synchronous mode when completion timing is not what the test is checking. The test waits for the operation to finish before checking its result. section 21.4.3

A time-service stub

A stub time service can fire time-change events immediately during a time-shift step, letting the test check the result without waiting for asynchronous behavior. section 21.4.3

Before choosing this approach, weigh its convenience against what synchronous execution may hide:

  • It can simplify a test when asynchronous timing is incidental. section 21.4.3
  • It may change system behavior and miss issues such as thread-safety problems, creating false positives. section 21.4.3 section 21.5

How Effective Behavior-Driven Development covers it

How deep it goes
Defines the pattern, gives a stubbed time-service example, and warns that synchronous execution can hide concurrency defects.
Examples
Uses a background job and a stub time service that fires events immediately.
What you can do after
Apply it by running normally asynchronous work synchronously when timing is incidental, while assessing risks from the changed execution mode.
How it connects
Links to asynchronous operations, Stub Dependency, Active Waiting, and Completed Event patterns.

Also explained in

Compare how 2 books explain synchronous testing →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Effective Behavior-Driven Development. The section links point to the parts of the book it draws on.