Hi Johannes, thank you very much for this amazing series on unit testing! I am an Applied Scientist and I find this super useful. I have a question: The purpose of unit testing seems to be testing each function we write when isolated from any other dependencies, just to check if our logic is correct. Does this mean that testing this once is enough. Because even if we add new functions to our code base, the unit tests for the ones we already completed would not change. Unless we modify the existing methods as well. Is this understanding right? And if we want to check if my existing functions are still working properly with the new function additions, then we need to resort to other sorts of testing like regression which you mentioned. If we happen to modify our existing methods, then we will need to rewrite our unit tests. Please let me know your thoughts
Hi Sateesh, yeah your understanding is correct. in unit testing you want to test your functions as isolated as possible. Once you have unit tests for your functions in place those wont change as long as your functions don't change... if your functions change you might need to adapt your unit tests. When you add new functions you would then also add new unit tests for those... over time this will build a robust test harness... and it will help you to make sure everything behaves as it should... because at some point it is not feasible anymore to manually test things as your application grows... If you want to test your functions without isolating the dependencies.. like for example execute real DB calls.. and ensure that the connection to the actual DB is working... then you would do something like integration testing...
Hi Johannes, thank you very much for this amazing series on unit testing! I am an Applied Scientist and I find this super useful. I have a question:
The purpose of unit testing seems to be testing each function we write when isolated from any other dependencies, just to check if our logic is correct. Does this mean that testing this once is enough. Because even if we add new functions to our code base, the unit tests for the ones we already completed would not change. Unless we modify the existing methods as well.
Is this understanding right?
And if we want to check if my existing functions are still working properly with the new function additions, then we need to resort to other sorts of testing like regression which you mentioned.
If we happen to modify our existing methods, then we will need to rewrite our unit tests.
Please let me know your thoughts
Hi Sateesh, yeah your understanding is correct. in unit testing you want to test your functions as isolated as possible. Once you have unit tests for your functions in place those wont change as long as your functions don't change... if your functions change you might need to adapt your unit tests.
When you add new functions you would then also add new unit tests for those... over time this will build a robust test harness... and it will help you to make sure everything behaves as it should... because at some point it is not feasible anymore to manually test things as your application grows...
If you want to test your functions without isolating the dependencies.. like for example execute real DB calls.. and ensure that the connection to the actual DB is working... then you would do something like integration testing...
@@JohannesFrey awesome! Thank you so much for the detailed and quick reply! 😄