liveBook · Manning

Unit test

As explained in Vibe Engineering

A unit test evaluates an isolated software unit, such as a function or class, against expected behavior.

A unit test evaluates an isolated software unit, such as a function or class, against expected behavior. It provides fast, focused verification and acts as a small contract: the assertion states what the code must do without prescribing its implementation. section 8.3.2 section 8.3.7

Use unit tests as a foundation, but treat passing tests as limited evidence:

  • Write assertions around requirements and invariants rather than implementation details, so tests remain useful when the implementation changes. section 8.3.7
  • Expect obvious examples to pass while hidden failures remain in edge cases such as nesting, malformed input, empty input, whitespace, links, and Unicode. section 8.3.2
  • Combine unit tests with integration tests, human review, CI, property-based testing, mutation testing, and security checks according to system criticality. section 8.8.4 section 8.8.2

Parser behavior and a malformed result

A first test set checks headers, bold, italic, and links. Additional tests combine formatting and nesting. The nested case exposes malformed output, <strong>bold and <em>italic</strong></em>, showing why happy-path tests do not establish parser correctness.

2025-04-04T09:30:07.550+02:00  INFO 23589 --- [io-8080-exec-10] o.j.a.q.k.service.MemberRegistration     : Registering Tasz
Hibernate: select m1_0.id,m1_0.email,m1_0.name,m1_0.phone_number from member m1_0 order by m1_0.name
Hibernate: select m1_0.id,m1_0.email,m1_0.name,m1_0.phone_number from member m1_0 order by m1_0.name
Hibernate: select m1_0.id,m1_0.email,m1_0.name,m1_0.phone_number from member m1_0 order by m1_0.name
Hibernate: select m1_0.id,m1_0.email,m1_0.name,m1_0.phone_number from member m1_0 order by m1_0.name
But then it is not able to retrieve all the members, it returns only:
ID    Name    Email    Phone Number
0    John Smith    john.smith@mailinator.com    2125551212

Logs expose a member-list persistence failure; adapting unit tests to require the missing save operation helps confirm the fix alongside QA retesting. section 2.7.3

How Vibe Engineering covers it

How deep it goes
Explains behavioral contracts and correlated blind spots through parser tests, but stops short of exhaustive specification or correctness proof.
Examples
Demonstrates parser assertions, nested-formatting failures, and database-save regression coverage during member registration.
What it assumes
Assumes isolated functions or classes and expected outputs, while teaching how to distinguish obvious cases from unenumerated edge cases.
What you can do after
Diagnose/debug with focused assertions, express required behavior as contracts, and catch regressions before broader integration checks.
How it connects
Connects unit tests with integration testing, CI, code coverage, property-based testing, mutation testing, and human review.

Also explained in

Compare how 18 books explain unit test →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Vibe Engineering. The section links point to the parts of the book it draws on.