Unit Test Your Dev Environment

February 13th, 2009
[ Geek ]

This is likely one of those parties I just happen to be late showing up for, move along if this sounds like old news. I had an issue this weekend related to having the wrong version of a framework running in one of my development environments. It eventually became clear that was the issue as the bug only existed on one machine, worked fine on others.

This isn’t the first time I’ve been bitten by this pattern of bug and it won’t be the last. My guess is you’d be hard pressed to find a developer who hasn’t ran into this. In an attempt to put this headache to bed once and for all, I added a test to the unit test suite that scrapes the version of all the required frameworks and validates they’re the ones expected. Hopefully I’ll spot this issue quicker next time it hits.

(trying syntaxhighlighter for the first time)

        # check elixir
        import elixir
        version = elixir.__version__
        self.assertEqual(self._elixir_ver, version,
                "Incorrect Elixir version, expected '%s', local is '%s'" %
                (self._elixir_ver, version))

  • Gord

    Only way I know of to remedy this type of bug is to strictly enforce the entire development team to use the same platform, packages, and tools. This is done by distributing specific installers or better yet putting all third party dependencies in your source tree. Instead of forcing the code writers to test other peoples’ environments for version numbers, have a standard setup that each developer follows religiously.

    To steal from my grade 9 science teacher: if you don’t control the variables, how can you expect your results to be repeatable?