• I do more manual unit testing of each piece of code I write in SQL Server. I haven't really invested in what tools are available to make this easier, but I do test each unit befoe committing. I did however read some articles from Microsoft on 2012 unit tests, but they looked very complex and for 2012. I'm on 2008 R2 still.

    I was thinking about porting the unittest module from Python to SQL to see if it could be benefitial. Here is a core example of how easy it is to test some string methods.

    Reading over the code, assertEqual is called to test for an expected result, assertTrue or assertFalse to test for conditions and assertRaises to test for specific exceptions. All 3 tests are ran with the results returned to the end user.

    import unittest

    class TestStringMethods(unittest.TestCase):

    def test_upper(self):

    self.assertEqual('foo'.upper(), 'FOO')

    def test_isupper(self):

    self.assertTrue('FOO'.isupper())

    self.assertFalse('Foo'.isupper())

    def test_split(self):

    s = 'hello world'

    self.assertEqual(s.split(), ['hello', 'world'])

    # check that s.split fails when the separator is not a string

    with self.assertRaises(TypeError):

    s.split(2)

    if __name__ == '__main__':

    unittest.main()