Earlier quoted context omitted.
Oh I remember working with "manual" testers tasked with automating software integration tests. Developers end up writing all the tests.
Sorry for such a juvenile question (I've only worked on small projects by myself before, but I'll be at my first internship with a large company ay the end of this month), but when should I even write unit tests? And should I write them for every function? Even the trivial ones? What defines trivial? Also, how about functions that write to a database? Should I refactor the code to separate the db writes and the compu…
However, don't test the compiler/interpreter and don't test your framework/libraries. Tests shouldn't look like this:
def test_foo():
foo = Foo(a=1, b=2, c=3)
assert foo.a == 1
assert foo.b == 2
assert foo.c == 3
This test will never fail and won't tell you anything. Don't test your dependencies code if you're using active, popular packages. Test that your code passes in the right values, and handles any errors that could happen in a reasonable manner.The time savings you can get out of a good test suite are almost limitless. Good test save lots of time in development and prevent broken things from making it to production.