Sign in Get 3 free credits

Try a job or a niche: tiktok captions, study notes, excel formulas. Press Esc to close.

Testing Without Mocks

Makes code testable with the Nullables pattern instead of mocking libraries, for fast and reliable unit tests.

Claude's review

7/10 Clear Nullables procedure with where to cut, layer rules and anti patterns, a real alternative to mock heavy tests.

We asked Claude the question you would ask: would I be glad I installed this? We only sell skills it rates 7 or higher.

In detail

Nullables — testing technique alternative to using mocking libraries. Use when writing unit tests, when code touches external I/O or state (HTTP, databases, files, clock, random) anywhere in its dependency chain, when making a system testable, or when tests are slow or flaky.

How you use it

  1. Add it to your pack, then download your pack (1 credit).
  2. In Claude, open Customize > Skills and upload the zip. Code execution needs to be on under Settings > Capabilities.
  3. Ask Claude for the job in your own words. It uses the skill when your request matches what it does. Step by step guide

Safety check

Nothing risky found: no hidden instructions, no download and run, no reading of saved passwords or keys.

An automated scan lowers risk but cannot promise zero risk. How we check skills

Preview

The first lines of SKILL.md
---
name: nullables
description: Nullables — testing technique alternative to using mocking libraries. Use when writing unit tests, when code touches external I/O or state (HTTP, databases, files, clock, random) anywhere in its dependency chain, when making a system testable, or when tests are slow or flaky.
---

# Nullables: Testing Without Mocks

STARTER_CHARACTER = ⭕️

Nullables are production code with an off switch: classes with external I/O anywhere in their dependencies offer `create()` (real) and `createNull()` (I/O disabled, everything else runs normally). Tests are narrow (focused on one class), sociable (dependencies run for real), and state-based (assert outputs and state, never method calls). Don't use mocking libraries or DI frameworks — Nullables make them unnecessary.

## The cut

Stub at the lowest point — the third-party edge — never your own code:

```
OrderService  →  PaymentClient  →  HttpClient  →  third-party lib
  app code       high-level        low-level       ✂ stubbed when nulled
                 wrapper           wrapper
```

- `PaymentClient` is a high-level wrapper: it abstracts one *service* and speaks domain language.
- `HttpClient` is a low-level wrapper: it abstracts one *technology* and is generic and highly reusable.
- The low-level wrapper holds the fork: `create()` wires the real library (node http, RestTemplate); `createNull()` wires an embedded stub — your code, returning canned data, doing no I/O.
- Everything left of the cut is your code and runs for real in tests.

With mocks, you only mock code you own; with Nullables, you only stub code you *don't* own. Only the bottom layer has a stub — one per technology. Everything above runs real in tests, so a bug anywhere in your code turns tests red. Mocking your own classes breaks that chain: mocked code never runs, and its bugs hide behind green tests.

An invented internal seam is the same break in disguise: cutting at `rows() → List<Row>` instead of the driver puts your mapping loop below the seam, where nulled tests never run it. The test: any parsing, mapping, or normalization you wrote must sit *above* the cut. When the third-party API is a chain of objects, mirror it — one stub class can play the whole chain (see the low-level wrapper files).

## Two channels, plus events

Every class that talks to infrastructure anywhere in its dependencies offers the same two factory methods:

```javascript
Clock.create()                            // production: the real system clock
Clock.createNull({ now: "2024-01-01" })   // test: frozen time, no external state
```

Tests interact with a nulled instance through three moves:
...

From lexler's repository, Apache-2.0 licence.

Related skills

  • Checked

    React Native tests

    Writes and fixes React Native component tests with Testing Library v13 and v14, using the right API for each.

    by callstackincubator 1.7k
    7/101 credit
  • Checked

    JUnit and Mockito tests

    Writes and fixes Java tests with JUnit, AssertJ and Mockito that are deterministic and keep failures visible.

    by github 42k
    8/101 credit
  • Checked

    Test code review

    Reviews new or changed tests in pytest, Jest, Go and more, so weak tests are caught before merge.

    by amElnagdy 1.3k
    8/101 credit
  • Checked

    Test scope decisions

    Decides which tests a change needs and how to judge their quality, for unit, integration and UI tests.

    by shinpr 725
    8/101 credit
  • Checked

    Playwright accessibility tests

    Writes Playwright and axe tests for WCAG, focus and ARIA, so accessibility bugs fail the build early.

    by fugazi 273
    7/101 credit
  • Checked

    Go table driven tests

    Writes Go tests with table cases, fakes, fuzzing, benchmarks and golden files that stay fast and reliable.

    by ericrisco 691
    8/101 credit

Secure checkout

Credits

AUD

  1. 1Choose
  2. 2Pay on Square
  3. 3Credits added