9 Commits

Author SHA1 Message Date
Olivier Mengué
603c2a0348 assert,require: enable parallel testing on (almost) all top tests
Enable parallel testing for almost all tests in packages 'assert' and
'require' by calling t.Parallel() as the first line of the test.

A few tests are incompatible and will be fixed separately. They are
marked with a FIXME.
Incompatible tests: TestFileExists, TestNoFileExists, TestDirExists,
TestNoDirExists.

Before:
  $ go test -count=10 ./assert ./require
  ok  	github.com/stretchr/testify/assert	7.575s
  ok  	github.com/stretchr/testify/require	1.501s

After:
  $ go test -count=10 ./assert ./require
  ok  	github.com/stretchr/testify/assert	1.703s
  ok  	github.com/stretchr/testify/require	1.245s
2025-05-23 16:17:12 +02:00
Bart Venter
9fc264e324
assert: add IsNotType (#1730)
Add the `IsNotType` assertion, which is the inverse
of the existing `IsType` assertion. It allows users to assert that an
object is not of a specific type.

Additionally, minor documentation improvements were made.

## Summary
This PR adds a new assertion function, `IsNotType`, to the
`testify/assert` package. It complements the existing `IsType` function
by providing a way to assert that an object is not of a specific type.

## Changes
* Added the `IsNotType` function to the `assert` package.
* Wrote unit tests for `IsNotType` to ensure correctness.
* Updated documentation to include examples and usage for `IsNotType`.

## Motivation
The `testify/assert` package already provides an `IsType` function to
check if an object is of a specific type. However, there was no built-in
way to assert that an object is **not** of a specific type. This PR
addresses that gap by introducing the `IsNotType` function, improving
the library's completeness and usability.

## Example usage
```go
assert.IsNotType(t, &MyStruct{}, actualObject)
```

## Related issues
_N/A_
2025-05-22 11:45:11 +02:00
Alun Evans
6990a05d54 Add ErrorContains 2021-01-16 12:32:05 +11:00
Nobuhiro MIKI
0224ef258e Add YAMLEq to assert that two YAML strings are equivalent 2019-07-11 17:50:32 -06:00
Julian Cooper
2933ed99aa Deleted monolithic TestJSONEqWrapper from forward_requirements_test 2015-10-13 14:15:08 -07:00
Julian Cooper
7f6cb13c5c split JSONEq tests into individual assertions from one monolithic test 2015-10-13 13:36:47 -07:00
Julian Cooper
930ea90dbd Added assertion/requirement that checks if two JSON strings represent equivalent objects 2015-09-23 10:34:52 -07:00
Will Faught
8512261d41 Add Zero and NotZero assertions and requirements
Zero returns true if the value equals the value's type's zero value.

NotZero returns the opposite of Zero.
2015-08-24 15:53:36 -07:00
Andreas Garnæs
49c0f07da4 Add require.Assertions like assert.Assertions. 2015-01-06 16:39:32 +00:00