liveBook · Manning

External testing

As explained in Learn Go with Pocket-Sized Projects

External testing tests a Go package from a separate package context and can access only the package's exposed declarations.

External testing checks a Go package from the user’s point of view, so tests can access only exposed declarations. Place the tests in a {packagename}_test package in the same folder. section 2.1.2

Use external testing to:

  • Verify the package’s stable, exposed API rather than its unexposed implementation details. section 2.1.2 section 4.0
  • Keep external and internal tests complementary: external tests check exposed behavior, while internal tests can reach unexposed functions. section 2.1.2

How Learn Go with Pocket-Sized Projects covers it

How deep it goes
Defines the package boundary and test-file placement, but does not detail external-test implementation steps.
Examples
Uses {packagename}_test files in the same folder as the package under test.
What it assumes
Assumes familiarity with Go packages and distinguishes exposed declarations from unexposed functions.
What you can do after
Evaluate a Go package’s publicly exposed behavior without depending on unexposed functions.
How it connects
Connects package APIs with internal testing, exposed declarations, and unexposed functions.

This explainer was generated by Manning's knowledge graph from the text of Learn Go with Pocket-Sized Projects. The section links point to the parts of the book it draws on.