I need help. I want to improve. I feel that I'm not writing the best unit tests. Can you guys recommend any books or articles where I can learn how especially in Python? I'm more concerned about strategies about knowing what tests to write and when is the best scenario to write them. I really want to be good at development and this area is what I think I'm lacking.
I'd really appreciate your help. Thank you.
My best advice for you is to write modular functions that can be tested separately rather than integrated stuff that can't be disentangled.<p>A unit test should test the functionality of a single chunk of code. What kind of stuff are you writing?<p>I write webservers most of the time. So what I do is, at the top level of the request, immediately pull data off of the request so that I can access to the data in native python types that are easy to mock for testing. Each layer of my webserver does only one thing which could be gluing the auth+services together, but is still easy to mock.
You might have a look at the O'Reilly book from August 2, 2017: "Test-Driven Development with Python: Obey the Testing Goat: Using Django, Selenium, and JavaScript" 2nd Edition