25 Apr '13, 6am
Fighting test pollution with an RSpec custom ordering strategy via @pivotallabs
Test pollution manifests itself as seemingly false negatives or false positives in a test suite. It occurs when some shared state is unintentionally modified, or unintentionally read and used in a test. When test pollution builds up, it can mean that a project’s build fails unpredictably, which can stop a whole team from shipping code regularly. This is an expensive way to not build software. Here’s an example of test pollution. You can save and run it with Ruby if you like. You shouldn’t need anything but a recent version of Ruby. If you run it several times, it will sometimes fail and sometimes pass: require 'minitest/autorun' class User def self.login(username, password) if username == 'fred' && password == '123' @logged_in = true end end def self.logged_in? @logged_in == true end end class UserTest < MiniTest::Unit::TestCase def test_logs_in_if_correct_credentials_used...