Przejdź do treści
Biblioteka skilli
Programowanie · Przegląd i audyt

assertion-strength

/assertion-strength

Sprawdza asercje w testach i oznacza osłabione sprawdzenia, pominięte testy i połykane wyjątki w zmianach.

Repozytorium
honest-tests ↗
Licencja
MIT
Ostatnia zmiana repozytorium
10.11.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 10.11.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Sprawdza asercje w testach i oznacza osłabione sprawdzenia, pominięte testy i połykane wyjątki w zmianach.

Oryginalny opis (EN)

Use when writing or editing test assertions, and when any test diff adds skip, xfail, a try/except, a snapshot, or a looser assertion to get green. Catches assert result, assert x is not None, assertTrue(x), toBeTruthy, toBeDefined, type-only checks, assertion-free tests, unreviewed snapshots, exceptions swallowed in tests, skipped or deleted tests, and assertions loosened in the same diff. Includes a static scanner with a git-diff mode.

Jak działa

  1. Steps
  2. Output contract
  3. Works with
Sekcje z nagłówków SKILL.md, w oryginale · 49 linii, 453 słów
Podgląd SKILL.md
---
name: assertion-strength
description: Use when writing or editing test assertions, and when any test diff adds skip, xfail, a try/except, a snapshot, or a looser assertion to get green. Catches assert result, assert x is not None, assertTrue(x), toBeTruthy, toBeDefined, type-only checks, assertion-free tests, unreviewed snapshots, exceptions swallowed in tests, skipped or deleted tests, and assertions loosened in the same diff. Includes a static scanner with a git-diff mode.
---

# Assertion Strength

A strong assertion names the exact value the code must produce. If a wrong implementation could still satisfy the assertion, it is not an assertion.

`<skill-dir>` means the folder that contains this SKILL.md. The scanner is `../test-roast/scripts/smell_scan.py` (standard library only).

## Steps

1. **Scan the tests and the test diff:**
   ```bash
   python <skill-dir>/../test-roast/scripts/smell_scan.py tests/ --diff --group assertion
   ```
   Rules: `no-assert`, `weak-assert` (every check is truthy, `is not None`, `isinstance`, `> 0`, `toBeDefined`, `typeof`), `tautology` (`assert True`, `expect(x).toBe(x)`), `swallowed-exception` (try/except or try/catch with no assertion), `skipped`, `snapshot`, and in `--diff` mode `deleted-test`, `added-skip`, `loosened` (strong assertions removed or replaced by weak ones in one hunk). Exit code 1 means at least one BAD finding.

2. **Rewrite every flagged assertion:**

   | Weak | Strong |
   |---|---|
   | `assert result` | `assert result == {"id": 7, "total": 90.0}` |
   | `assert x is not None` | `assert x == expected` (keep `is not None` only when "absent" is the bug) |
   | `assertTrue(len(items))` | `assertEqual(items, ["a", "b"])` |
   | `expect(fn()).toBeTruthy()` | `expect(fn()).toBe(42)` |
   | `try: f() except: pass` | `with pytest.raises(ValueError, match="qty"):` |
   | `toMatchSnapshot()` alone | read the snapshot, then assert the 1-2 fields that matter |
   | `assert abs(a-b) < 100` | `pytest.approx(b, rel=1e-6)` with a tolerance justified by the maths |

3. **Test boundaries, not only the middle.** For every comparison in the changed code (`>=`, `<`, `==`) assert the value on each side of the edge (9, 10, 11 for `>= 10`). For every branch, one test that takes each side. For every raised error, one test that expects that error type and message.

4. **Never make a test green by loosening it.** If a test fails after your change, one of three things is true: the code is wrong (fix the code), the requirement changed (change the expected value and say so explicitly), or the test was flaky (fix the cause). Adding `skip`, `xfail`, `.only`, a wider tolerance, a catch-all `except`, or deleting the test is not a fix. If you must remove or skip a test, say which one and why, in the final message.

5. **Prove it.** Run `mutation-check`. Weak assertions are exactly what produce surviving mutants.

## Output contract

```
Assertion strength: <files scanned>
- Tests scanned: <n> | flagged: <n>
- Rewritten: <test name -> the exact assertion now used>
- Skipped/xfail/deleted tests in this change: <list with a reason each, or "none">
- Assertions loosened in this change: <list, or "none">
- Boundaries asserted: <comparison -> values on each side>
- Scanner exit code after the changes: <0|1> | mutation-check score: <pct>%
```

## Works with

`mock-audit` handles mock-only tests. `done-means-verified` requires a red-to-green proof. `mutation-check` is the objective test of assertion strength.

Wersje

W bazie nie ma innych skilli o nazwie assertion-strength.

Migawka bazy z 13.11.2026 · wersja paczki 58ed409e004c (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100overfit-assertion-quality
    Analizuje różnorodność i głębokość asercji w zestawach testów w dowolnym języku: wykrywa testy bez asercji, trywialne i tautologiczne asercje oraz ocenia zróżnicowanie pokrycia asercjami.
  • 100improving-weak-tests
    Przepisuje słaby test jednostkowy tak, by wychwytywał mutacje, zastępując toBeTruthy, toBeDefined, puste sprawdzenia mocków, migawki bez kształtu i podglądanie stanu prywatnego.
  • 100test-anti-patterns
    Audytuje pliki testów i wskazuje antywzorce: testy bez asercji, zbyt szerokie wyjątki, testy niestabilne i duplikacje, z oceną wagi.
  • 100test-assertion-quality
    Sprawdza własny test przed wysłaniem pod kątem pustych asercji, testów kodu źródłowego i wycieków fixtures między testami.
  • 100assertion-quality
    Analizuje jakość, głębokość i różnorodność asercji w istniejących testach (MSTest, Jest, pytest, Go), wykrywając słabe, trywialne, zawsze prawdziwe i pozorne asercje.
  • 100test-assertions
    Pisze asercje jako pełne, ścisłe porównania równości i przepisuje istniejące testy do tego samego standardu.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.