I just do not get some of these matchers. Unit tests are meant to be consistent and repeatable, so I would be interested to find why you think there is a need for such matchers as the "in range" and "is even" ? Surely the tests should be: given a number x it is guaranteed to give number y. If you can not guarantee the output then it seems the code being tested has a smell, this being that it depends on global state.
My name is Gil Zilberfeld, and with my colleague Roy Osherove, we do a little cast called This week in testing.
This week we mention the new matcher feature, and talk about the Google mocking framework. I invite you to watch. If you like what you see, please talk about us, so more people can enjoy.
I just do not get some of these matchers. Unit tests are meant to be consistent and repeatable, so I would be interested to find why you think there is a need for such matchers as the "in range" and "is even" ?
ReplyDeleteSurely the tests should be:
given a number x it is guaranteed to give number y. If you can not guarantee the output then it seems the code being tested has a smell, this being that it depends on global state.
Hi Zhanyong,
ReplyDeleteMy name is Gil Zilberfeld, and with my colleague Roy Osherove, we do a little cast called This week in testing.
This week we mention the new matcher feature, and talk about the Google mocking framework. I invite you to watch. If you like what you see, please talk about us, so more people can enjoy.
Thanks,
Gil Zilberfeld
Typemock