Comments (3)
Parking for now. If anyone feels strongly in favour of the feature then feel free to post your reasoning.
from testify.
So this is like the well known generic Must()
, but rather than converting non-nil errors to a panic, it converts non-nil errors to a fatal test failure.
Would assert.Must
exist? Would it be a non-fatal test failure? If it did then it would feel very wrong calling it "must". Probably it would only apply to require.
You only show usage in test setup, which is not the primary purpose of test assertions. How does this look in a test assertion?
actual := require.Must(t, codeundertest.GetData(arg))
require.Equal(t, expected, actual)
Sure, maybe, but do we also need Must2, Must3 etc.. Because type parameters cannot be variadic. It looks like Go is not going to add Must to the standard library: golang/go#32219
In my view this turns 3 lines into 2 for test assertions, 2 lines into 1 for test setup. At best it doesn't make the test more readable. I don't think we should include this.
from testify.
Rethinking it, I agree that it doesn't look to suit this project enough.
You only show usage in test setup, which is not the primary purpose of test assertions. How does this look in a test assertion?
Your example looks appropriate. More clear one:
// setup
x := Setup()
// act
x.MethodUnderTest()
// assertion
actual := require.Must(t, x.Get())
require.Equal(t, expected, actual)
Anyway probably it will mostly used for setup.
In my view this turns 3 lines into 2 for test assertions, 2 lines into 1 for test setup. At best it doesn't make the test more readable. I don't think we should include this.
Now I agree with you. I'd thought that it it turns 10 lines into 5 lines for test setup and it makes sense. However, probably we should just write a setup function if setup needs 10 lines.
from testify.
Related Issues (20)
- assert fails and expects to dereference a reference HOT 1
- Add GoLang 1.22 to CI Testing Matrix for Package Compatibility Verification HOT 2
- error while importing github.com/stretchr/testify/suite: read C:\Program Files\Go\src\math\huge_test.go: unexpected NUL in input HOT 1
- AnythingOfType is marked deprecated on pkgsite HOT 1
- .On().Return() doesn't enforce expectation for the returned value HOT 1
- v1.9.0 breaks float comparisons with EqualValues HOT 6
- mock: cleanup argument matching API HOT 7
- Integer overflow in time.Time comparison
- EqualExportedValues can compare two slices HOT 2
- Regexp accepts interface{} HOT 3
- Drop outdated/abandoned dependencies HOT 3
- Proposal: assert.NotElementsMatch() HOT 4
- assert: invalid memory address or nil pointer dereference for assert.Error on darwin/arm64 HOT 1
- mock: Diff is prone to data races
- call.Unset() panics when call := mockObj.On("Foo", mock.AnythingOfType("foo")) HOT 1
- Proposal: assert.NoFieldIsEmpty HOT 13
- Feature request: add BeforeSetupTest and AfterTearDownTest HOT 3
- Misleading Error() docs HOT 3
- assert: Eventually should not leak a goroutine HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from testify.