Grégoire Paris
89086b0757
Document consequences of calling t.FailNow()
...
These comments are adapted from t.FailNow()'s own documentation.
Closes #1701
2025-03-19 20:50:44 +01:00
Arjun Dhawan
7d99b2b43d
attempt 2
2024-10-27 08:07:57 +01:00
Arjun Dhawan
05f87c0160
more similar
2024-10-27 08:05:00 +01:00
Arjun Dhawan
ea7129e006
better fmt
2024-10-27 08:02:53 +01:00
Arjun Dhawan
be992afabf
trial
2024-10-24 13:28:30 +02:00
Arjun Dhawan
fb67df6392
no regression
2024-10-24 11:40:45 +02:00
Arjun Dhawan
822223ec34
fix name regression
2024-10-24 11:30:00 +02:00
Arjun Dhawan
22d3bd5def
in order to remain compatible with go1..19, don't compare function names (but do include them in the diff output)
2024-10-24 11:30:00 +02:00
Arjun Dhawan
9c174eb41c
fix: compare functional option names for indirect calls
...
Closes Functional Options testing broken for indirect calls #1380
2024-10-24 11:30:00 +02:00
Bracken
a012e45d18
Merge pull request #1636 from rainhq/jayd3e.fix_return_arguments
...
Record Return Arguments of a Call
2024-10-16 14:07:58 +01:00
Oleksandr Redko
ba3e7c34d5
mock: fix doc comment for NotBefore
2024-10-04 18:06:40 +03:00
Bracken
85a526818c
Merge branch 'master' into master
2024-10-02 17:21:55 +01:00
Spirin
f3f7181b01
Merge branch 'master' into unexpected-method-caller-info
2024-10-01 02:22:07 +03:00
Bracken
72e3b61028
Merge branch 'master' into mock-simplify-FunctionalOptions-impl
2024-09-30 23:28:38 +01:00
spirin
ea6964c2e9
mock: caller information for unexpected method call
2024-09-30 21:33:46 +03:00
Reynier Ortiz
f17409f81f
mock: in order mock calls
...
(requested changes applied)
2024-09-25 12:03:55 -04:00
Reynier Ortiz
7268a5bc0b
mock: in order mock calls
2024-09-06 09:18:07 -04:00
Joseph Dallago
da63673a11
Now properly record the ReturnArguments as part of the call.
2024-08-29 22:05:04 +03:00
Bracken
8d4dcbbccb
Merge pull request #1569 from stretchr/mock-more-AnythingOfTypeArgument-alternatives
...
mock: document more alternatives to deprecated AnythingOfTypeArgument
2024-04-23 16:15:28 +00:00
Olivier Mengué
8c324a0bbd
mock: simpler deprecation doc for AnythingOfTypeArgument
...
Co-authored-by: Bracken <abdawson@gmail.com>
2024-04-23 15:23:21 +02:00
Olivier Mengué
d4a63f5b89
mock: simplify implementation of FunctionalOptions
...
Remove unnecessary use of reflect in the implementation of
mock.FunctionalOptions().
2024-04-22 23:10:37 +02:00
Snir Yehuda
da1e1476cb
Merge branch 'master' into master
2024-03-18 09:47:57 +02:00
Olivier Mengué
3c302f75ae
mock: improve doc ( #1570 )
...
## Summary
Improve API doc of package
[`mock`](https://pkg.go.dev/github.com/stretchr/testify/mock ):
- add godoc links
- indent example code
## Motivation
Readability.
2024-03-10 11:42:04 +01:00
Olivier Mengué
aca1890ec1
mock: document more alternatives to deprecated AnythingOfTypeArgument
2024-03-07 11:59:12 +01:00
Snir Yehuda
f1b5324b90
assert.FunctionalOptions: fix go doc
2024-03-06 11:28:50 +03:00
Tom Wright
cab2acc70f
Do not get argument again unnecessarily in Arguments.Error()
2024-03-06 03:03:10 +01:00
Bracken
c719de3088
Merge pull request #1331 from ianrose14/ianrose/assertexpectations-skipped
...
Ensure AssertExpectations does not fail in skipped tests
2024-02-17 17:50:13 +00:00
Ian Rose
1837f62a5f
Ensure AssertExpectations does not fail in skipped tests
2023-10-31 00:00:55 +01:00
Olivier Mengué
307c9344b8
mock: refactor IsType
...
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.
2023-10-16 13:57:23 +02:00
Olivier Mengué
413628c0f4
mock: simplify Arguments.Diff
...
Use a type switch instead of reflect.TypeOf comparisons.
2023-10-16 13:57:23 +02:00
Olivier Mengué
f24f3ba986
mock: deprecate AnythingOfTypeArgument ( #1434 )
...
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.
2023-08-08 11:05:09 +02:00
Anant Vyas
a23f5db224
mock: move regexp compilation outside of Called ( #631 )
...
Co-authored-by: Olivier Mengué <dolmen@cpan.org>
2023-08-01 10:07:29 +02:00
Olivier Mengué
862e41010c
Merge pull request #1360 from hikyaru-suzuki/feature/update_logging_output
...
mock: AssertExpectations log reason only on failure
2023-07-29 05:52:15 +02:00
Ed
9f0f17fe64
Correct spelling/grammar
2023-05-26 10:38:59 +01:00
Harald Nordgren
4c93d8f201
EqualExportedValues: Handle nested pointer, slice and map fields ( #1379 )
...
* EqualExportedValues: Handle pointer and slice fields
* Update assert/assertions.go
Co-authored-by: Michael Pu <michael.pu123@gmail.com>
* Reduce redundant calls to 'copyExportedFields'
* Update comments
* Add support for maps
* Update Go version support to 1.19 and onward
* Re-generate after rebasing
---------
Co-authored-by: Michael Pu <michael.pu123@gmail.com>
2023-05-11 07:42:04 +10:00
Nisheeth Barthwal
b3106d772c
allow testing for functional options ( #1023 )
...
* allow testing for functional options
* add linting docs
* use reflect magic to obtain FunctionalOption name
Co-authored-by: dillonstreator <dillonstreator@gmail.com>
---------
Co-authored-by: dillonstreator <dillonstreator@gmail.com>
2023-05-10 06:55:48 +10:00
鈴木 光
75b9b6dfff
update: log reason output only if failed
2023-03-09 18:49:15 +09:00
lisitsky
2b00d33aec
Fix Call.Unset() panic (issue #1236 ) ( #1250 )
...
Unset changes len of a `ExpectedCalls` slice during iteration while using index from original slice, and under some conditions it tries to reslice element beyond of the slice boundaries. That causes panic.
The proposed solution uses independent write index to count elements kept in output slice.
Tests (the simplest and more complicated cases) and comments are included.
2023-01-03 20:44:42 +10:00
Bracken
cf1284f8dd
Allow mock expectations to be ordered ( #1106 )
...
* Allow mock expectations to be ordered
* Only say another call if it has been called before
2022-06-28 22:13:45 +10:00
Edward Raigosa
b5ce165710
fixing panic in calls to assertion with nil m.mutex ( #1212 )
...
* fixing panic in calls to assertion with nil m.mutex
This reverts a change that was made in https://github.com/stretchr/testify/pull/1182
The PR makes m.mutex a pointer which now needs to be checked but it's not checked for nil everywhere.
This should also help with these issues:
- https://github.com/stretchr/testify/issues/1208
- https://github.com/stretchr/testify/issues/1210
* Revert throwing out the lock because other concurrent calls can already have it locked
* fix go vet copy lock by using pointer
* fix obj assignment for passing test
2022-06-24 10:11:59 +10:00
Bracken
c206b2e823
Mock can be deadlocked by a panic ( #1157 )
...
If an argumentMatcher function panics and AssertExpectations is deferred then the test would deadlock.
2022-06-23 19:42:21 +10:00
Paul Dufour
ba1076d8b3
Add .Unset method to mock ( #982 )
...
* Add .Off method to mock
* Update README.md
* Update mock.go
* Update mock_test.go
* Update README.md
* Fix tests
* Add unset test
* remove prints
* fix test
* update readme
2022-06-22 19:31:35 +10:00
Tony Abboud
48391ba5eb
Fix panic in AssertExpectations for mocks without expectations ( #1207 )
...
Co-authored-by: Tony Abboud <tabboud@palantir.com>
2022-06-21 07:08:00 +10:00
Boyan Soubachov
3c33e07c4c
Added Go 1.18.1 as a build/supported version ( #1182 )
...
* Added Go 1.18.1 as a build/supported version
Removed Go 1.15.13 as a build version as it's no longer supported
* Fix mutex passed by value for the Mock struct
* Add mutex initialisation for Mock
Co-authored-by: Boyan Soubachov <bsoubachov@atlassian.com>
2022-06-14 20:50:25 +10:00
perrydunn
e209ca88af
Improve mock.MatchedBy failed comparison Diff message
2021-08-24 20:26:52 +10:00
neilisaac
6241f9ab99
Add String method to Mock to fix #625
2021-04-27 21:38:32 +10:00
Bo Sunesen
acba37e5db
Only use repeatability if no repeatability left
2021-01-13 20:54:11 +11:00
Bo Sunesen
a5830c56d3
Extract method to evaluate closest match
2021-01-13 20:54:11 +11:00
Bo Sunesen
1962448488
Use Repeatability as tie-breaker for closest match
2021-01-13 20:54:11 +11:00
Yaroslav Kolomiiets
3bf8d0aa5e
callString not to panic on nil
...
Fixes stretchr/testify#936 .
2020-04-29 21:10:54 +10:00