-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add opportunity to trigger setup/teardown for subtest #1246
Add opportunity to trigger setup/teardown for subtest #1246
Conversation
very important feature for table-tests. Lets merge it |
Hi! Can somebody check it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you for your contribution :)
When will the next release be? :) |
Also would love a new release for this feature:) |
ehy, any news on when this will be released? :) |
Also waiting for the release o/ |
Just released in v1.8.2 |
This MR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github.com/stretchr/testify](https://github.com/stretchr/testify) | require | minor | `v1.8.0` -> `v1.9.0` | --- ### Release Notes <details> <summary>stretchr/testify (github.com/stretchr/testify)</summary> ### [`v1.9.0`](https://github.com/stretchr/testify/releases/tag/v1.9.0) [Compare Source](stretchr/testify@v1.8.4...v1.9.0) #### What's Changed - Fix Go modules version by [@​SuperQ](https://github.com/SuperQ) in stretchr/testify#1394 - Document that require is not safe to call in created goroutines by [@​programmer04](https://github.com/programmer04) in stretchr/testify#1392 - Remove myself from MAINTAINERS.md by [@​mvdkleijn](https://github.com/mvdkleijn) in stretchr/testify#1367 - Correct spelling/grammar by [@​echarrod](https://github.com/echarrod) in stretchr/testify#1389 - docs: Update URLs in README by [@​davidjb](https://github.com/davidjb) in stretchr/testify#1349 - Update mockery link to Github Pages in README by [@​LandonTClipp](https://github.com/LandonTClipp) in stretchr/testify#1346 - docs: Fix typos in tests and comments by [@​alexandear](https://github.com/alexandear) in stretchr/testify#1410 - CI: tests from go1.17 by [@​SuperQ](https://github.com/SuperQ) in stretchr/testify#1409 - Fix adding ? when no values passed by [@​lesichkovm](https://github.com/lesichkovm) in stretchr/testify#1320 - codegen: use standard header for generated files by [@​dolmen](https://github.com/dolmen) in stretchr/testify#1406 - mock: AssertExpectations log reason only on failure by [@​hikyaru-suzuki](https://github.com/hikyaru-suzuki) in stretchr/testify#1360 - assert: fix flaky TestNeverTrue by [@​dolmen](https://github.com/dolmen) in stretchr/testify#1417 - README: fix typos "set up" vs "setup" by [@​ossan-dev](https://github.com/ossan-dev) in stretchr/testify#1428 - mock: move regexp compilation outside of `Called` by [@​aud10slave](https://github.com/aud10slave) in stretchr/testify#631 - assert: refactor internal func getLen() by [@​dolmen](https://github.com/dolmen) in stretchr/testify#1445 - mock: deprecate type AnythingOfTypeArgument ([#​1434](stretchr/testify#1434)) by [@​dolmen](https://github.com/dolmen) in stretchr/testify#1441 - Remove no longer needed assert.canConvert by [@​alexandear](https://github.com/alexandear) in stretchr/testify#1470 - assert: ObjectsAreEqual: use time.Equal for time.Time types by [@​tscales](https://github.com/tscales) in stretchr/testify#1464 - Bump actions/checkout from 3 to 4 by [@​dependabot](https://github.com/dependabot) in stretchr/testify#1466 - Bump actions/setup-go from 3.2.0 to 4.1.0 by [@​dependabot](https://github.com/dependabot) in stretchr/testify#1451 - fix: make EventuallyWithT concurrency safe by [@​czeslavo](https://github.com/czeslavo) in stretchr/testify#1395 - assert: fix httpCode and HTTPBody occur panic when http.Handler read Body by [@​hidu](https://github.com/hidu) in stretchr/testify#1484 - assert.EqualExportedValues: fix handling of arrays by [@​zrbecker](https://github.com/zrbecker) in stretchr/testify#1473 - .github: use latest Go versions by [@​kevinburkesegment](https://github.com/kevinburkesegment) in stretchr/testify#1489 - assert: Deprecate EqualExportedValues by [@​HaraldNordgren](https://github.com/HaraldNordgren) in stretchr/testify#1488 - suite: refactor test assertions by [@​alexandear](https://github.com/alexandear) in stretchr/testify#1474 - suite: fix SetupSubTest and TearDownSubTest execution order by [@​linusbarth](https://github.com/linusbarth) in stretchr/testify#1471 - docs: Fix deprecation comments for http package by [@​alexandear](https://github.com/alexandear) in stretchr/testify#1335 - Add map support doc comments to Subset and NotSubset by [@​jedevc](https://github.com/jedevc) in stretchr/testify#1306 - TestErrorIs/TestNotErrorIs: check error message contents by [@​craig65535](https://github.com/craig65535) in stretchr/testify#1435 - suite: fix subtest names (fix [#​1501](stretchr/testify#1501)) by [@​dolmen](https://github.com/dolmen) in stretchr/testify#1504 - assert: improve unsafe.Pointer tests by [@​dolmen](https://github.com/dolmen) in stretchr/testify#1505 - assert: simplify isNil implementation by [@​dolmen](https://github.com/dolmen) in stretchr/testify#1506 - assert.InEpsilonSlice: fix expected/actual order and other improvements by [@​dolmen](https://github.com/dolmen) in stretchr/testify#1483 - Fix dependency cycle with objx [#​1292](stretchr/testify#1292) by [@​dolmen](https://github.com/dolmen) in stretchr/testify#1453 - mock: refactor TestIsArgsEqual by [@​dolmen](https://github.com/dolmen) in stretchr/testify#1444 - mock: optimize argument matching checks by [@​dolmen](https://github.com/dolmen) in stretchr/testify#1416 - assert: fix TestEventuallyTimeout by [@​dolmen](https://github.com/dolmen) in stretchr/testify#1412 - CI: add go 1.21 in GitHub Actions by [@​dolmen](https://github.com/dolmen) in stretchr/testify#1450 - suite: fix recoverAndFailOnPanic to report test failure at the right location by [@​dolmen](https://github.com/dolmen) in stretchr/testify#1502 - Update maintainers by [@​brackendawson](https://github.com/brackendawson) in stretchr/testify#1533 - assert: Fix EqualValues to handle overflow/underflow by [@​arjunmahishi](https://github.com/arjunmahishi) in stretchr/testify#1531 - assert: better formatting for Len() error by [@​kevinburkesegment](https://github.com/kevinburkesegment) in stretchr/testify#1485 - Ensure AssertExpectations does not fail in skipped tests by [@​ianrose14](https://github.com/ianrose14) in stretchr/testify#1331 - suite: fix deadlock in suite.Require()/Assert() by [@​arjunmahishi](https://github.com/arjunmahishi) in stretchr/testify#1535 - Revert "assert: ObjectsAreEqual: use time.Equal for time.Time type" by [@​brackendawson](https://github.com/brackendawson) in stretchr/testify#1537 - \[chore] Add issue templates by [@​arjunmahishi](https://github.com/arjunmahishi) in stretchr/testify#1538 - Update the build status badge by [@​brackendawson](https://github.com/brackendawson) in stretchr/testify#1540 - Update Github workflows setup-go to V5 by [@​hendrywiranto](https://github.com/hendrywiranto) in stretchr/testify#1545 - Support Pointer to Struct in EqualExportedValues by [@​Lucaber](https://github.com/Lucaber) in stretchr/testify#1517 - README: drop link to gorc by [@​guettli](https://github.com/guettli) in stretchr/testify#1248 - http_assertions: honour the msgAndArgs provided with each assertion by [@​arjunmahishi](https://github.com/arjunmahishi) in stretchr/testify#1548 - fix typos in comments and tests by [@​ccoVeille](https://github.com/ccoVeille) in stretchr/testify#1247 - Include the auto-release notes in releases by [@​brackendawson](https://github.com/brackendawson) in stretchr/testify#1550 - Add `NotImplements` and variants by [@​hslatman](https://github.com/hslatman) in stretchr/testify#1385 - Add support to compare uintptr by [@​bogdandrutu](https://github.com/bogdandrutu) in stretchr/testify#1339 - build(deps): bump github.com/stretchr/objx from 0.5.1 to 0.5.2 by [@​dependabot](https://github.com/dependabot) in stretchr/testify#1552 #### New Contributors - [@​SuperQ](https://github.com/SuperQ) made their first contribution in stretchr/testify#1394 - [@​programmer04](https://github.com/programmer04) made their first contribution in stretchr/testify#1392 - [@​echarrod](https://github.com/echarrod) made their first contribution in stretchr/testify#1389 - [@​davidjb](https://github.com/davidjb) made their first contribution in stretchr/testify#1349 - [@​LandonTClipp](https://github.com/LandonTClipp) made their first contribution in stretchr/testify#1346 - [@​alexandear](https://github.com/alexandear) made their first contribution in stretchr/testify#1410 - [@​lesichkovm](https://github.com/lesichkovm) made their first contribution in stretchr/testify#1320 - [@​dolmen](https://github.com/dolmen) made their first contribution in stretchr/testify#1406 - [@​hikyaru-suzuki](https://github.com/hikyaru-suzuki) made their first contribution in stretchr/testify#1360 - [@​ossan-dev](https://github.com/ossan-dev) made their first contribution in stretchr/testify#1428 - [@​aud10slave](https://github.com/aud10slave) made their first contribution in stretchr/testify#631 - [@​tscales](https://github.com/tscales) made their first contribution in stretchr/testify#1464 - [@​czeslavo](https://github.com/czeslavo) made their first contribution in stretchr/testify#1395 - [@​hidu](https://github.com/hidu) made their first contribution in stretchr/testify#1484 - [@​zrbecker](https://github.com/zrbecker) made their first contribution in stretchr/testify#1473 - [@​kevinburkesegment](https://github.com/kevinburkesegment) made their first contribution in stretchr/testify#1489 - [@​linusbarth](https://github.com/linusbarth) made their first contribution in stretchr/testify#1471 - [@​jedevc](https://github.com/jedevc) made their first contribution in stretchr/testify#1306 - [@​craig65535](https://github.com/craig65535) made their first contribution in stretchr/testify#1435 - [@​arjunmahishi](https://github.com/arjunmahishi) made their first contribution in stretchr/testify#1531 - [@​ianrose14](https://github.com/ianrose14) made their first contribution in stretchr/testify#1331 - [@​hendrywiranto](https://github.com/hendrywiranto) made their first contribution in stretchr/testify#1545 - [@​Lucaber](https://github.com/Lucaber) made their first contribution in stretchr/testify#1517 - [@​guettli](https://github.com/guettli) made their first contribution in stretchr/testify#1248 - [@​ccoVeille](https://github.com/ccoVeille) made their first contribution in stretchr/testify#1247 - [@​hslatman](https://github.com/hslatman) made their first contribution in stretchr/testify#1385 - [@​bogdandrutu](https://github.com/bogdandrutu) made their first contribution in stretchr/testify#1339 **Full Changelog**: stretchr/testify@v1.8.4...v1.9.0 ### [`v1.8.4`](https://github.com/stretchr/testify/releases/tag/v1.8.4) [Compare Source](stretchr/testify@v1.8.3...v1.8.4) #### What's Changed - Create GitHub release when new release tag is pushed by [@​aldas](https://github.com/aldas) in stretchr/testify#1354 #### New Contributors - [@​aldas](https://github.com/aldas) made their first contribution in stretchr/testify#1354 **Full Changelog**: stretchr/testify@v1.8.3...v1.8.4 ### [`v1.8.3`](https://github.com/stretchr/testify/releases/tag/v1.8.3) [Compare Source](stretchr/testify@v1.8.2...v1.8.3) #### What's Changed - Compare public elements of struct by [@​mchlp](https://github.com/mchlp) in stretchr/testify#1309 - assert: fix error message formatting for NotContains by [@​wwade](https://github.com/wwade) in stretchr/testify#1362 - allow testing for functional options by [@​nbaztec](https://github.com/nbaztec) in stretchr/testify#1023 - add EventuallyWithT assertion by [@​tobikris](https://github.com/tobikris) in stretchr/testify#1264 - EqualExportedValues: Handle nested pointer, slice and map fields by [@​HaraldNordgren](https://github.com/HaraldNordgren) in stretchr/testify#1379 #### New Contributors - [@​mchlp](https://github.com/mchlp) made their first contribution in stretchr/testify#1309 - [@​wwade](https://github.com/wwade) made their first contribution in stretchr/testify#1362 - [@​nbaztec](https://github.com/nbaztec) made their first contribution in stretchr/testify#1023 - [@​tobikris](https://github.com/tobikris) made their first contribution in stretchr/testify#1264 **Full Changelog**: stretchr/testify@v1.8.2...v1.8.3 ### [`v1.8.2`](https://github.com/stretchr/testify/releases/tag/v1.8.2) [Compare Source](stretchr/testify@v1.8.1...v1.8.2) #### What's Changed - Add opportunity to trigger setup/teardown for subtest by [@​qerdcv](https://github.com/qerdcv) in stretchr/testify#1246 - fix: fix bug for check unsafe.Pointer isNil by [@​sunpe](https://github.com/sunpe) in stretchr/testify#1319 - Fix Call.Unset() panic (issue [#​1236](stretchr/testify#1236)) by [@​lisitsky](https://github.com/lisitsky) in stretchr/testify#1250 - Fix `CallerInfo()` source file paths by [@​bozaro](https://github.com/bozaro) in stretchr/testify#1288 - assert: Fix Subset/NotSubset when map is missing keys from the subset by [@​danielwhite](https://github.com/danielwhite) in stretchr/testify#1261 #### New Contributors - [@​qerdcv](https://github.com/qerdcv) made their first contribution in stretchr/testify#1246 - [@​sunpe](https://github.com/sunpe) made their first contribution in stretchr/testify#1319 - [@​lisitsky](https://github.com/lisitsky) made their first contribution in stretchr/testify#1250 - [@​bozaro](https://github.com/bozaro) made their first contribution in stretchr/testify#1288 - [@​danielwhite](https://github.com/danielwhite) made their first contribution in stretchr/testify#1261 **Full Changelog**: stretchr/testify@v1.8.1...v1.8.2 ### [`v1.8.1`](https://github.com/stretchr/testify/releases/tag/v1.8.1) [Compare Source](stretchr/testify@v1.8.0...v1.8.1) #### What's Changed - Bump github.com/stretchr/objx from 0.4.0 to 0.5.0 by [@​dependabot](https://github.com/dependabot) in stretchr/testify#1283 **Full Changelog**: stretchr/testify@v1.8.0...v1.8.1 </details> --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yODYuMSIsInVwZGF0ZWRJblZlciI6IjM3LjI4Ni4xIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=--> See merge request alpine/infra/build-server-status!12
Without this mocks are not verified as expected (every table-test case'). While this would work, one might expect behavior like ``` for _, tt := range testcases { t.Run(tt.name, func(t* testing.T) { init-controller-and-mocks // test-code // mocks are verified here, at the end of subtest } } ``` Unfortunately, that's not the behavior you get with `s.Run(subtest func())` as controller is not re-initialized. In order to addres this gap testify introduced `SetupSubTest/TearDownSubTest` in v1.8.2 See stretchr/testify#1246 for more details
Without this mocks are not verified as expected (every table-test case'). While this would work, one might expect behavior like ``` for _, tt := range testcases { t.Run(tt.name, func(t* testing.T) { init-controller-and-mocks // test-code // mocks are verified here, at the end of subtest } } ``` Unfortunately, that's not the behavior you get with `s.Run(subtest func())` as controller is not re-initialized. In order to addres this gap testify introduced `SetupSubTest/TearDownSubTest` in v1.8.2 See stretchr/testify#1246 for more details
Without this mocks are not verified as expected (every table-test case'). While this would work, one might expect behavior like ``` for _, tt := range testcases { t.Run(tt.name, func(t* testing.T) { init-controller-and-mocks // test-code // mocks are verified here, at the end of subtest } } ``` Unfortunately, that's not the behavior you get with `s.Run(subtest func())` as controller is not re-initialized. In order to addres this gap testify introduced `SetupSubTest/TearDownSubTest` in v1.8.2 See stretchr/testify#1246 for more details
Without this mocks are not verified as expected (every table-test case'). While this would work, one might expect behavior like ``` for _, tt := range testcases { t.Run(tt.name, func(t* testing.T) { init-controller-and-mocks // test-code // mocks are verified here, at the end of subtest } } ``` Unfortunately, that's not the behavior you get with `s.Run(subtest func())` as controller is not re-initialized. In order to addres this gap testify introduced `SetupSubTest/TearDownSubTest` in v1.8.2 See stretchr/testify#1246 for more details SubTest behavior was fixed in v1.9.0 - otherwise failed mock expectations made parent test to fail, but child still succeeded. See stretchr/testify#1471 for more details
Summary
Add opportunity to setup or teardown each subtest
Changes
Motivation
I find very useful to have opportunity to setup/tear down subtest, and I decide to try add it.
Example usage
Related issues
Closes: #1031
Closes: #832