3 ms·
Getting people to write tests is hard. Getting them to write matchers... it’s like you’re asking them to fly. Which is a shame because you can avoid so, so much
by hinkley 7y ago
Getting people to write tests is hard. Getting them to write matchers... it’s like you’re asking them to fly. Which is a shame because you can avoid so, so much test boilerplate by writing a high quality custom matcher.
- hashtagMERKY 7y agoNot a software engineer, sorry. What’s a matcher? Google didn’t help.
- hinkley 7y agoNot to worry. Some test frameworks do not expose them, so people often don’t even to know to want for them. User allover did a respectable job of explaining.
- antsar 7y agoIME (python webdev) most test frameworks do expose some form of this, but I’ve never heard them called “matchers”. So perhaps people know & use them, but not by that name.
- hinkley 7y agoI mean expose the ability to write your own. When I first used them, I thought all frameworks allowed this, then bumped into some that didn't, or at least not in the popular version at the time.
- jfkebwjsbx 7y agoWhat do you mean by matcher?
- allover 7y ago> "matchers" [...] let you test values in different ways Example docs for Jest's matchers: https://jestjs.io/docs/en/using-matchers https://jestjs.io/docs/en/using-matchers Generally speaking, if you use a specific matcher, you get a better (more informative) error message when the test fails.
- jfkebwjsbx 7y agoAh, the common testing functions like `assert_equal`. Thanks!
- hinkley 7y agoRight, and some APIs let you write your own. Getting a custom one to hand out actionable error messages is a bit tricky but quite worth it.