Skip to content

Testing ​

Run your App's tests from the Project root. Start with the service tests from Your First Route, then check photo persistence and photo job dispatch as you add those features.

bash
go test ./...

Expected result: packages report ok or [no test files]. A failure identifies the package and test to inspect first. GoForj also generates tests for enabled framework components such as lifecycle, readiness, and database connections.

Choose a Test Layer ​

Start with the test that proves the behavior you changed.

Behavior to proveStart withAdd a broader test when
Services, repositories with fakes, and pure domain behaviorUnit Tests with go test ./...Generated wiring or a real backend changes the result
Controllers, route groups, and generated HTTP behaviorHTTP Tests with httptestListener or full-App behavior is the point
Console commandsCommand TestsGenerated registration or runtime composition matters
Job handlers and dispatchJob and Queue TestsRetries, worker lifecycle, shutdown, or backend behavior matters
Event publishing and subscribersEvent TestsDelivery through an external backend matters
Cache and storage behaviorCache and Storage TestsDriver-specific semantics matter
Database, external backends, or App boundariesIntegration Tests with go test -tags=integration ./...You need to verify the App's runtime setup too

Keep Domain Behavior Direct ​

Test services and the code called by jobs, event subscribers, and scheduled tasks through their constructors. Use fakes for isolated service rules and temporary local backends for persistence or delivery checks. Keep generated registration and runtime startup in tests of those boundaries.

Local infrastructure drivers can keep broader tests small:

  • use inproc for event delivery
  • use a compiled sync or workerpool queue driver for local delivery
  • use null when no-op queue behavior is the contract

Maintainer Workflows ​

When you change the GoForj templates or generators, run the rendered Project smoke and integration tests against a disposable App.

  • Getting Started introduces the first local application path.
  • Operations explains runtime behavior that integration tests should verify.