If it’s at the start of every test it’s completely redundant.
If it’s at the start of every test it’s completely redundant.
The valuable advice here is that a test function should be named to reflect what it is testing rather that the name of the function it calls.
Depending on the test library you use, there’s already in built stuff for this.
The prefix is not the point, but it might help to write better names for tests:
- can handle negative input
- cannot handle zero
- should return a http error code
Might be better than:
- test calcultate negative
- test calcultate zero
- test handler http code
It was a nice way to learn implicit rules in an applied manner.
(Sorry for the nonstandard punctuation, but it's necessary here.)
- handles_negative_input
- handles_zero
- returns_http_error_code
- negative_input
- zero_input
- bad_request
When you run the "bad_request" test, you should get an error code, but that's on the assert already.
Will also admit that I was a big DSL fan back in the ruby heyday. Works great if it's only you on the project but requiring a whole team to be DSL domain experts for something like testing is asking quite a lot.