Skip to content

Conversation

aepfli
Copy link
Member

@aepfli aepfli commented Feb 15, 2025

Our tests are great, but often we rely on our own Singleton for testing purposes. This can create concurrency issues or make testing really hard. By instantiating a own API object for each test we ensure that we are not messing with each other.
Furthermore we should not use .getInstance() within our own implementation, which is now ensured with an ArchUnit test

@aepfli aepfli requested a review from a team as a code owner February 15, 2025 09:47
@aepfli aepfli changed the title test: Reduce usage of singelton withint our tests test: Reduce usage of singelton within our tests Feb 15, 2025
@aepfli aepfli force-pushed the feat/improve-tests branch 5 times, most recently from 65dab59 to 0ff7ece Compare February 15, 2025 10:40
@aepfli aepfli changed the title test: Reduce usage of singelton within our tests test: Reduce usage of singelton within our tests and implementations Feb 15, 2025
@aepfli aepfli force-pushed the feat/improve-tests branch 3 times, most recently from 20b50c7 to be2a2f5 Compare February 15, 2025 10:54
Our tests are great, but often we rely on our own Singelton for testing purposes.
This can create concurrency issues or make testing really hard.
By instantiating a own API object for each test we ensure that we are not messing
with each other.
Furthermore we should not use `.getInstance()` within our own implementation.

Signed-off-by: Simon Schrottner <[email protected]>
@aepfli aepfli force-pushed the feat/improve-tests branch from be2a2f5 to 22824c8 Compare February 15, 2025 11:15
Copy link

codecov bot commented Feb 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.23%. Comparing base (e163ce1) to head (d56ad52).
Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1331      +/-   ##
============================================
+ Coverage     93.04%   93.23%   +0.19%     
- Complexity      466      467       +1     
============================================
  Files            43       43              
  Lines          1121     1123       +2     
  Branches         90       90              
============================================
+ Hits           1043     1047       +4     
+ Misses           49       48       -1     
+ Partials         29       28       -1     
Flag Coverage Δ
unittests 93.23% <100.00%> (+0.19%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Member

@justinabrahms justinabrahms left a comment

Choose a reason for hiding this comment

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

I quite like this! The one concern I have would be people not using the singleton causing issues.

@aepfli
Copy link
Member Author

aepfli commented Feb 16, 2025

I quite like this! The one concern I have would be people not using the singleton causing issues.

The good part is, the constructor is not public but protected, and always have been. Hence either people need to extend the API object, or have to be in the same package. This is already possible, so we are actually not changing anything regarding this behavior

@aepfli aepfli force-pushed the feat/improve-tests branch 2 times, most recently from c324962 to 739204d Compare February 17, 2025 08:54
@aepfli aepfli force-pushed the feat/improve-tests branch from 739204d to f53d459 Compare February 17, 2025 10:16
Signed-off-by: Simon Schrottner <[email protected]>
@aepfli aepfli force-pushed the feat/improve-tests branch from f53d459 to 93e14f7 Compare February 17, 2025 11:12
Copy link

@toddbaert toddbaert self-requested a review February 18, 2025 18:02
@aepfli aepfli merged commit 88baa65 into open-feature:main Feb 18, 2025
11 checks passed
@aepfli aepfli deleted the feat/improve-tests branch February 18, 2025 18:19
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.

4 participants