Closed linusg closed 5 years ago
Omg, this is so weird. Just a few moments ago, all builds were passing without problems. I have no idea how to make these tests more stable while actually keeping them in.
For now, I am going to keep re-running the tests on Travis until they pass lol.
EDIT: They finally did pass.
I hope this is temporary: https://travis-ci.org/ritiek/spotify-downloader/jobs/439046788#L575
Yep, this seems to be an issue with travis-ci itself.
I have no idea how to make these tests more stable while actually keeping them in.
The thumb rule with tests (unit testing) is that when you have to make a network request (or something similar which you can't necessarily test), is to mock it.
Mocking in our case would be giving the function the html that is required for the function.
Mocking the tests will ensure that they won't fail when youtube changes something. But the problem with mocking tests are they won't fail when youtube changes something. (See what I did there :smile_cat:)
So if we want our CI to not fail occasionally, we can mock the tests. If we want to catch when yt actually changes something we have to live with these occasional failures.
What are your thoughts on this?
NOTE: I initially thought mocking tests were a joke. But I have grown to respect them more nowadays.
The thumb rule with tests (unit testing) is that when you have to make a network request (or something similar which you can't necessarily test), is to mock it.
That sounds like a neat idea indeed!
So if we want our CI to not fail occasionally, we can mock the tests. If we want to catch when yt actually changes something we have to live with these occasional failures.
I'd prefer to see the CI passing if our code changes are correct, not failing because of YouTube changing something - which we would notice after a short amount of time anyway (someone opens an issue or we experience the issue ourselves).
So the way I see it the tests should indicate whether our code is correct.
I monkeypatched them in #448.
What is the purpose of your issue?
Description
Any chance we can (finally) make the tests more stable? It's a bummer to see those failing because some YouTube video search ended not up as expected, it makes it kind of hard to quickly notice real broken builds!
E.g. the latest: https://travis-ci.org/ritiek/spotify-downloader/jobs/426367358