Sorry if this is a really dumb question but I've been searching for ages and just can't figure it out.
So I have a question about unit testing, not necessarily about Python, but since I'm working with Python at the moment I chose to base my question on it.
I get the idea of unit testing, but the only thing I can find on the internet are the very simple unit tests. Like testing if the method sum(a, b) returns the sum of a + b.
But how do you apply unit testing when dealing with a more complex program? As an example, I have written a crawler. I don't know what it will return, else I wouldn't need the crawler. So how can I test that the crawler works properly without knowing what the method will return?
Thanks in advance!
Unit testing verifies that your code does what you expect in a given environment. You should make sure all other variables are as you expect them to be and test your single method. To do that for methods which use third party APIs, you should probably mock them using a mocking library. By mocking you provide data you expect and verify that your method works as expected. You can also try to separate your code so that the part which makes API request and the part that parses/uses it are separate and unit test that second part with a certain API example response you provide.
Python - unit testing