This fix adds panic handling for subtests which will achieve:
- subtests will fail for the correct test context when panicking
- the test execution is not stopped; the next subtest will be executed
There were two problems with the order of execution in the Suite.Run() method:
- One could not access the correct testing context ("s.T()") inside the SetupSubTest and TearDownSubTest methods. If the testing context was used for e.g. assertions of mocks in the TearDownSubTest, the results would not be "attached" to the correct test in the test output.
- The behavior was different to the order of execution for "root" tests (see lines 167-201) regarding the SetupTest and TearDownTest methods. This could confuse users of the library.
Also the logic to be deferred was joined together. This was fine beforehand because a panic in the TearDownSubTest would have had no influence on the "suite.SetT(oldT)". Now since a panic in the TearDownSubTest would lead to omitting the "suite.SetT(oldT)" this defer was split into two separate defers.
Fix TestEventuallyIssue805 which was flaky because of the use of a timer
that has exactly the same duration as the Eventually timout. But time is
not a synchronization primitive.
Now we use channels to ensure that the condition is still running and
Eventually times out before checking its return value.
The test is also renamed to TestEventuallyTimeout to more clearly show
its purpose.
Reduce calls to reflect.Type in implementation of mock.IsType by
extracting the type early.
This also avoids to keep alive references to the argument value.
In go.mod exclude the old version of testify brought by objx. This
allows to break the dependency cycle and completely remove the
dependency link to old versions of dependencies (some of which had
security issues).
Closes#1292.
go mod edit -exclude=github.com/stretchr/testify@v1.8.2 && go.mod
Deprecate mock.AnythingOfTypeArgument which should never have been
publicly exposed.
AnythingOfTypeArgument is now a type alias to the private
anythingOfTypeArgument and is marked as Deprecated in godoc.
The AnythingOfType constructor is still available.
The aim is to completely remove that alias.
Reverse order of return values of internal function getLen() to be more
consistent with stdlib (ex: os.LookupEnv).
Old: func (any) (ok bool, length int)
New: func (any) (length int, ok bool)