The test is passing even when the AsyncTask fails to fetch the joke (Example- If the backend is offline).
In my AsyncTask's doInBackground method, I have-
catch (IOException e) {
return e.getMessage();
}
So, when an error occurs and an exception is caught, the AsyncTask will return a string representing the error message. Hence, the test will pass even when the AsyncTask failed to fetch the joke as the string is not null.
The source code of the project:
https://github.com/AhmedHamdan54/BuildItBigger2
Edit 1: One friend told me that I can solve making the catch statement return a specific String and the test make sure it doesn't return that String to pass. But I don't know how to make it.