1. 11

  2. 8

    We need another suffix. “Considered Harmful” is too overused.

    1. 4

      Considered harmful considered harmful?

    2. 7

      Can’t agree with this enough. One of the biggest problems I see, especially with people using mocking frameworks, is that they’re not testing behavior, they’re tracing code.

      1. 6

        This test can actually be useful.

        I had a monotonically increasing integer to identify objects in the system. These IDs would be publicly visible, inviting people to scrape them, so I primed the RNG and shuffled the bits. They have all the same properties I need, but it’s far less likely someone will iterate over them.

        I had a test that throwing a particular number into the shuffle got a particular number back out. This was deliberately a change-detector test. It didn’t care if a shuffle was done reversibly, or maintaing the same number of 1 bits, or do anything more to verify correct behavior than this article’s second example.

        The test failed once because the Ruby stdlib random number generator changed and the array was sorted differently. Without this test I would’ve started generating duplicate IDs. I was able to handwrite a new stable version and the system continued happily. The test is still there.

        1. 2

          Heartily agreed. Especially for functions I’ve optimized I’ve found it helpful to retain the inefficient but supposedly equivalent definition and test that the two achieve equivalent results for all inputs.

        2. 1

          Literally days if not weeks were thrown away dealing with change detector tests at a former startup I was at. I’d like to blame it on https://code.google.com/p/pymox/ but really the person who wrote all those tests didn’t understand what mocking was and wasn’t for.

          1. 1


            for real, those tests sucked though. geez what a mistake