📖 2 min read (~ 400 words).
Quick API index
Domains
All assertions are classified into 19 domains to help navigate the API, depending on your use case.
API metrics
Counts for core functionality, and generated variants (formatted, forward, forward-formatted).
| Kind | Count | Note |
|---|
| All core functions | 135 | Maintained core |
| All core assertions | 131 | Usage with *testing.T |
| Generic assertions | 50 | Type-safe assertions (“T” suffix) |
| Helpers (not assertions) | 4 | General-purpose utilities, not assertions |
| Others | 0 | |
| assert/require variants | 424 | Generated variants |
| Total assertions variants | 848 | Available assertions API |
| Total API surface | 858 | |
Quick index
Table of core assertions, excluding variants. Each function is side by side with its logical opposite (when available).
| Assertion | Opposite | Domain | Kind |
|---|
| CallerInfo | | common | helper |
| Condition | | condition | |
| Consistently[C Conditioner] | | condition | |
| Contains | NotContains | collection | |
| DirExists | DirNotExists | file | |
| ElementsMatch | NotElementsMatch | collection | |
| ElementsMatchT[E comparable] | NotElementsMatchT | collection | |
| Empty | NotEmpty | equality | |
| Equal | NotEqual | equality | |
| EqualError | | error | |
| EqualExportedValues | | equality | |
| EqualT[V comparable] | NotEqualT | equality | |
| EqualValues | NotEqualValues | equality | |
| Error | NoError | error | |
| ErrorAs | NotErrorAs | error | |
| ErrorContains | | error | |
| ErrorIs | NotErrorIs | error | |
| EventuallyWith[C CollectibleConditioner] | | condition | |
| Eventually[C Conditioner] | Never | condition | |
| Exactly | | equality | |
| Fail | | testing | |
| FailNow | | testing | |
| FileEmpty | FileNotEmpty | file | |
| FileExists | FileNotExists | file | |
| Greater | LessOrEqual | comparison | |
| GreaterOrEqual | Less | comparison | |
| GreaterOrEqualT[Orderable Ordered] | LessT | comparison | |
| GreaterT[Orderable Ordered] | LessOrEqualT | comparison | |
| HTTPBody | | http | helper |
| HTTPBodyContains | HTTPBodyNotContains | http | |
| HTTPError | | http | |
| HTTPRedirect | | http | |
| HTTPStatusCode | | http | |
| HTTPSuccess | | http | |
| Implements | NotImplements | type | |
| InDelta | | number | |
| InDeltaMapValues | | number | |
| InDeltaSlice | | number | |
| InDeltaT[Number Measurable] | | number | |
| InEpsilon | | number | |
| InEpsilonSlice | | number | |
| InEpsilonT[Number Measurable] | | number | |
| IsDecreasing | IsNonDecreasing | ordering | |
| IsDecreasingT[OrderedSlice ~[]E, E Ordered] | IsNonDecreasingT | ordering | |
| IsIncreasing | IsNonIncreasing | ordering | |
| IsIncreasingT[OrderedSlice ~[]E, E Ordered] | IsNonIncreasingT | ordering | |
| IsOfTypeT[EType any] | IsNotOfTypeT | type | |
| IsType | IsNotType | type | |
| JSONEq | | json | |
| JSONEqBytes | | json | |
| JSONEqT[EDoc, ADoc Text] | | json | |
| JSONMarshalAsT[EDoc Text] | | json | |
| JSONUnmarshalAsT[Object any, ADoc Text] | | json | |
| Kind | NotKind | type | |
| Len | | collection | |
| MapContainsT[Map ~map[K]V, K comparable, V any] | MapNotContainsT | collection | |
| MapEqualT[K, V comparable] | MapNotEqualT | collection | |
| Nil | NotNil | equality | |
| NoFileDescriptorLeak | | safety | |
| NoGoRoutineLeak | | safety | |
| ObjectsAreEqual | | common | helper |
| ObjectsAreEqualValues | | common | helper |
| Panics | NotPanics | panic | |
| PanicsWithError | | panic | |
| PanicsWithValue | | panic | |
| Positive | Negative | comparison | |
| PositiveT[SignedNumber SignedNumeric] | NegativeT | comparison | |
| Regexp | NotRegexp | string | |
| RegexpT[Rex RegExp, ADoc Text] | NotRegexpT | string | |
| Same | NotSame | equality | |
| SameT[P any] | NotSameT | equality | |
| SeqContainsT[E comparable] | SeqNotContainsT | collection | |
| SliceContainsT[Slice ~[]E, E comparable] | SliceNotContainsT | collection | |
| SliceEqualT[E comparable] | SliceNotEqualT | collection | |
| SliceSubsetT[Slice ~[]E, E comparable] | SliceNotSubsetT | collection | |
| SortedT[OrderedSlice ~[]E, E Ordered] | NotSortedT | ordering | |
| StringContainsT[ADoc, EDoc Text] | StringNotContainsT | collection | |
| Subset | NotSubset | collection | |
| True | False | boolean | |
| TrueT[B Boolean] | FalseT | boolean | |
| WithinDuration | | time | |
| WithinRange | | time | |
| YAMLEq | | yaml | |
| YAMLEqBytes | | yaml | |
| YAMLEqT[EDoc, ADoc Text] | | yaml | |
| YAMLMarshalAsT[EDoc Text] | | yaml | |
| YAMLUnmarshalAsT[Object any, ADoc Text] | | yaml | |
| Zero | NotZero | type | |