Fix tests again
See original GitHub issue- Using latest version as provided on the master branch
- Searched for similar issues including closed ones
What is the purpose of your issue?
- Bug
- Feature Request
- Question
- Other
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
=================================== FAILURES ===================================
____________ TestYouTubeTitle.test_single_download_with_youtube_api ____________
self = <test_without_metadata.TestYouTubeTitle object at 0x7fc115278c18>
def test_single_download_with_youtube_api(self):
global content
global title
expect_title = "Tony's Videos VERY SHORT VIDEO 28.10.2016"
[1m key = 'AIzaSyAnItl3udec-Q1d5bkjKJGL-RgrKO_vU90'
const.args.youtube_api_key = key
youtube_tools.set_api_key()
content = youtube_tools.go_pafy(raw_song, metadata)
title = youtube_tools.get_youtube_title(content)
> assert title == expect_title
E assert 'Very short video' == "Tony's Videos VERY SHORT VIDEO 28.10.2016"
E - Very short video
E + Tony's Videos VERY SHORT VIDEO 28.10.2016
test/test_without_metadata.py:98: AssertionError
----------------------------- Captured stderr call -----------------------------
DEBUG: query: {'maxResults': 50, 'part': 'snippet', 'type': 'video', 'q': "Tony's Videos VERY SHORT VIDEO 28.10.2016"}
DEBUG: query_results: {'maxResults': 50, 'part': 'contentDetails,snippet,statistics', 'id': 'j0VwlUkxJmw,fK4SLPmxeY4,OE4dDJw5wAI,uRasm7397MM,plCGs8PYreo,Twkb_jXEPuU,sulRwNHbjcc,5USR1Omo7f0,AkDye53pE0M,XV4LCjRERlM,t-1vaOy8oPU,ouWRtZhVQSU,f1GUj4dKYc0,mrOPFt9E0eQ,YXeLqhkBjyA,FDL4C8oiJJg,F2gEzNbPDWA,9JISEn8rXis,B2lOBiN_RD8,qBNmY7S0BG8,cpoj2thH7WI,TbUIaV6qm1U,FmWUx7Uf6so,ghhOWJlKwHo,WgOTH0b2HDc,3H2EUKPZkxA,_mogWYk6ivE,nD4JmSv_rGo,roaIAdnGEJQ,mmcztns2a3w,J8HdWBKe4eQ,N2QZ6eo8Yfs,VqxLe7dbR14,rMPmpQBeESg,SzwpRcK5xfY,zsVF9Y4P8ho,thXtwk2_Jbg,vICQsxfjw5U,UQBnBFvxo4M,NgO3Rr9o-Hk,_yHtPPYyoBM,uFqO7A89DAY,QsEBPWeSOJ0,ZCzXDp_Mtug,c9AcYskh_0U,ZNxRXQRg1JU,YY2l--Vje7o,aBbemsM9d28,2--NFvaVgL4,0zbPVwnyacg'}
DEBUG: Since no metadata found on Spotify, going with the first result
===================== 1 failed, 52 passed in 78.21 seconds =====================
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
How to Fix Flaky Tests - Semaphore CI
Randomly failing tests are the hardest to debug. Here's a framework you can use to fix them and keep your test suite healthy....
Read more >The Evolution of Fixing Broken Tests - Functionize
Here is the evolution of fixing broken test cases and how ... Often this process has to be repeated again and again before...
Read more >Fix Your Failing Tests: A Debugging Checklist for React ...
Testing can become really frustrating when you get stuck debugging a long list of failing tests. Use this checklist to get back in...
Read more >What is Retesting? When We Do Retesting in Software ...
Retesting is running the previously failed test cases again on the new software to verify whether the defects posted earlier are fixed or ......
Read more >Fix your flaky tests problem - Undo.io
Eliminate flaky test failures with Software Failure Replay. Spend time eliminating flaky tests not investigating them. Fix intermittent failures fast.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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 😸)
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.
That sounds like a neat idea indeed!
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.