Re:Kent Beck: “I get paid for code that works, not for tests...
by emodendroket on Thursday December 08, 2016 @09:33AM
(#13130473)
There should be a law banning people from asserting the constants have the expected value in tests.
[ Parent
| on HN ]
Re:Kent Beck: “I get paid for code that works, not for tests...
by remar on Thursday December 08, 2016 @03:05PM
(#13133772)
I was taught that there should be tests against things like class constants so that you have a failing build in the event that someone changes a const that's part of the specification.
This was from some TDD course that my employer brought in where they emphasized that consts that are part of a specification or requirement should be tested against to prevent them from being accidentally changed or changed without full consideration of side effects/review against the program spec.
Is this what you're referring to?
Re:Kent Beck: “I get paid for code that works, not for tests...
by emodendroket on Thursday December 08, 2016 @04:01PM
(#13134263)
I guess so but I disagree with that teaching. All it does is make me change it in two places.
Re:Kent Beck: “I get paid for code that works, not for tests...
by nostrademons on Friday December 09, 2016 @02:42AM
(#13137330)
That's sorta the point - to make you think before you change. A constant without a test is part of the implementation, and you can refactor as necessary to make the implementation perform better. A constant with a test is part of the interface, and if you change it, client behavior has changed and the tests should change with it.
Re:Kent Beck: “I get paid for code that works, not for tests...
by aindhaden on Friday December 09, 2016 @10:50AM
(#13139371)
This is true only for a very particular kind of constants, like the ones defining API error codes (eg. define PAGE_NOT_FOUND 404). And those should be covered by integration tests, not unit tests.
Re:Kent Beck: “I get paid for code that works, not for tests...
by emodendroket on Friday December 09, 2016 @09:03AM
(#13138767)
Yes, OK, but what I'm telling you is I think it's just as mindless. If anything, I look less at the tests when I know I'm going to break fifty of them with any real change at all. "Yeah, yeah, whatever" and copying and pasting the new values is the more likely behavior in this scenario.
Re:Kent Beck: “I get paid for code that works, not for tests...
by wjnc on Thursday December 08, 2016 @09:39AM
(#13130517)
Do you mean test explicitly and fail graciously? So even test over false inputs, but check that the code fails with the right exit?
Re:Kent Beck: “I get paid for code that works, not for tests...
by emodendroket on Thursday December 08, 2016 @09:53AM
(#13130598)
I mean if you have a method whose definition is literally just "return 'abc'" and then you have a test assert that that method returns 'abc', knock it off.
Re:Kent Beck: “I get paid for code that works, not for tests...
by jdmichal on Thursday December 08, 2016 @10:49AM
(#13131010)
I call those types of test, "testing that the compiler works." Not really something you should be testing! It also applies to testing code that is just a wrapper around third-party libraries.