testify/require
Vladimir Kochnev b074924938
assert: collect.FailNow() should not panic (#1481)
## Summary
`collect.FailNow()` should exit goroutine without a panic to be usable
with `require` package.

## Changes
`collect.FailNow()` just does `runtime.Goexit()` instead of `panic()`.
For example `FailNow()` from `testing` package [behaves
similarly](https://cs.opensource.google/go/go/+/refs/tags/go1.21.2:src/testing/testing.go;l=973).

## Motivation

I just want `require` package to be usable with `EventuallyWithT` e.g. I
want this example to pass but it panics:

```go
package main

import (
	"testing"
	"time"

	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
)

func TestRequireEventuallyWithT(t *testing.T) {
	state := 0
	require.EventuallyWithT(t, func(c *assert.CollectT) {
		defer func() { state += 1 }()
		require.True(c, state == 2)
	}, 100*time.Millisecond, 10*time.Millisecond)
}
```

See https://go.dev/play/p/Oqd95IT7qxQ

## Related issues
Fixes https://github.com/stretchr/testify/issues/1396
Fixes https://github.com/stretchr/testify/issues/1457
2024-06-13 22:09:51 +02:00
..
doc.go EqualExportedValues: Handle nested pointer, slice and map fields (#1379) 2023-05-11 07:42:04 +10:00
forward_requirements.go Make _codegen its own module so that its dependencies do not pollute the root modules dependency graph 2019-12-09 10:12:49 -07:00
forward_requirements_test.go Add ErrorContains 2021-01-16 12:32:05 +11:00
require.go fix: grammar in godoc for NotErrorIs(f) functions (#1607) 2024-06-13 14:57:39 +02:00
require.go.tmpl Helper is called before assert function in require.* functions 2019-02-14 17:34:13 -07:00
require_forward.go fix: grammar in godoc for NotErrorIs(f) functions (#1607) 2024-06-13 14:57:39 +02:00
require_forward.go.tmpl Fix vim-go integration and other editors 2018-02-02 18:39:40 +00:00
requirements.go assert: make tHelper a type alias 2024-03-03 18:29:24 +01:00
requirements_test.go assert: collect.FailNow() should not panic (#1481) 2024-06-13 22:09:51 +02:00