Dynamic vs. static typing for testing

I once had a discussion with a fellow classmate during my masters degree days about dyanamic versus static typing in terms of effectiveness and time use. His argument was that static typing took up less time from the programmer since it didn't require writing as many unit tests to cover type safety issues for code. While this might seem true on the surface, a little bit more analysis would seem to suggest this is not totally true.

First of all, static typing requires extra typing when you ignore unit tests compared to a dynamic language. You not only have to type every defined variable but you will probably also have various casts lying about, leading to more typing. If you take all of that typing and use it for unit tests instead you probably don't have *too* much typing for the unit tests.

You can also just view them as similar. Static typing shifts testing on to the compiler while dynamic typing puts it to the programmer. Having the compiler do it has the perk of more reliability, but it restricts the type of testing you get for your typing. Dynamic programming is the oppositie: programmer has to do the tests himself which means possibly more errors, but they can be more more deep tests for the same amount of work.

Basically we came to the conclusion that static typing was not directly superior over dynamic typing from the testing point of you. While static typing may alleviate some basic tests for you, they can be easily covered in dynamic typing with unit tests that probably take only a little bit more typing than having to declare types, all the while having the possibility of being more in-depth tests.