Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "flaky" unit-tests #1072

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Fix "flaky" unit-tests #1072

wants to merge 3 commits into from

Conversation

BPerlakiH
Copy link
Collaborator

Fixes: #1071

After double checking our build issues, I realised that some unit-test results, are heavily dependent on User Defaults, which is a key/value storage by Apple, which is persisted across sessions.
By running the same Unit-tests several times (repeatedly without building) some of them might fail.

Proposed solution:

  • Wrap our user-default calls for those failing tests
  • Use a test instance instead, that won't persist the results
  • Also make sure that the created test db entries are cleaned-up properly

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 66.26506% with 28 lines in your changes missing coverage. Please review.

Project coverage is 23.93%. Comparing base (58f7577) to head (fcb4b99).

Files with missing lines Patch % Lines
ViewModel/LibraryViewModel.swift 40.00% 12 Missing ⚠️
Model/CategoriesToLanguage.swift 0.00% 8 Missing ⚠️
Model/Defaulting.swift 0.00% 4 Missing ⚠️
Views/Library/Library.swift 0.00% 2 Missing ⚠️
Views/Library/ZimFilesCategories.swift 0.00% 2 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (58f7577) and HEAD (fcb4b99). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (58f7577) HEAD (fcb4b99)
2 1
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1072       +/-   ##
===========================================
- Coverage   35.87%   23.93%   -11.95%     
===========================================
  Files         127      124        -3     
  Lines        7492     7016      -476     
===========================================
- Hits         2688     1679     -1009     
- Misses       4804     5337      +533     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kelson42
Copy link
Contributor

kelson42 commented Jan 7, 2025

CI is red!

Copy link
Member

@rgaudin rgaudin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, indeed

@rgaudin
Copy link
Member

rgaudin commented Jan 7, 2025

CI to be fixed before merging, obviously

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix "flaky" unit tests
4 participants