Awesome Reviewers

Reviewer · Testing

Test isolation and lifecycle management

Tests must be isolated and self-contained, with resource setup/teardown handled by framework-native utilities rather than manual boilerplate. This reduces the risk of shared state, leaked resources, or order-dependent failures.

Instruction

Tests must be isolated and self-contained, with resource setup/teardown handled by framework-native utilities rather than manual boilerplate. This reduces the risk of shared state, leaked resources, or order-dependent failures.

Guidelines:

  • Prefer built-in lifecycle helpers over manual setup/teardown. For example, in Ember use setupMirage(hooks) instead of manually instantiating and shutting down this.server — the helper handles cleanup automatically.
  • In Go, use t.TempDir() instead of manually creating and cleaning up temp directories; it is automatically removed after the test completes.
  • Mark tests as independent whenever possible by calling t.Parallel(). This both speeds up the test suite and forces tests to avoid shared state or ordering dependencies.
  • Group tests into suites/modules (e.g., Ember’s module(), Go subtests) only when they genuinely share setup/context (such as a common beforeEach), not purely for organizational nesting — excessive or arbitrary grouping adds confusion without benefit.
  • Always clean up any resources a test creates (servers, files, connections); if cleanup is skipped, state can leak between tests and cause flaky failures.

Example (Go):

func TestWriteFile(t *testing.T) {
    t.Parallel()
    dir := t.TempDir() // auto-cleaned after test
    // ... use dir ...
}

Example (Ember):

module('Integration | Component | my-component', function (hooks) {
  setupRenderingTest(hooks);
  setupMirage(hooks); // server lifecycle handled automatically

  hooks.beforeEach(function () {
    this.server.create('model', { id: 1, name: 'Test Item' });
  });
});