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

Improve test coverage of core unit tests #2294

Merged
merged 1 commit into from
Sep 30, 2024

Conversation

xgouchet
Copy link
Member

What does this PR do?

Add missing UT on some core module classes, and improve some UT for maintainability

@xgouchet xgouchet requested review from a team as code owners September 27, 2024 12:35
@xgouchet xgouchet force-pushed the xgouchet/reliability/coverage branch from 07b8460 to 810e356 Compare September 27, 2024 12:37
@codecov-commenter
Copy link

codecov-commenter commented Sep 27, 2024

Codecov Report

Attention: Patch coverage is 97.61905% with 1 line in your changes missing coverage. Please review.

Project coverage is 70.26%. Comparing base (4a7586e) to head (c1f2e34).
Report is 6 commits behind head on develop.

Files with missing lines Patch % Lines
.../android/core/internal/data/upload/UploadStatus.kt 95.83% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2294      +/-   ##
===========================================
+ Coverage    69.97%   70.26%   +0.29%     
===========================================
  Files          733      730       -3     
  Lines        27236    27259      +23     
  Branches      4576     4583       +7     
===========================================
+ Hits         19058    19152      +94     
+ Misses        6894     6832      -62     
+ Partials      1284     1275       -9     
Files with missing lines Coverage Δ
...d/core/internal/data/upload/RotatingDnsResolver.kt 95.83% <ø> (ø)
...ernal/persistence/datastore/DataStoreFileHelper.kt 93.75% <100.00%> (+78.75%) ⬆️
...ernal/persistence/datastore/DatastoreFileReader.kt 95.56% <100.00%> (ø)
...ernal/persistence/datastore/DatastoreFileWriter.kt 84.75% <100.00%> (ø)
...rsistence/file/batch/PlainBatchFileReaderWriter.kt 75.68% <ø> (ø)
...ternal/persistence/tlvformat/TLVBlockFileReader.kt 100.00% <ø> (ø)
...atadog/android/core/internal/utils/ByteArrayExt.kt 94.64% <100.00%> (+23.21%) ⬆️
...m/datadog/android/core/internal/utils/NumberExt.kt 50.00% <100.00%> (+50.00%) ⬆️
.../android/core/internal/data/upload/UploadStatus.kt 98.68% <95.83%> (+10.22%) ⬆️

... and 37 files with indirect coverage changes

return false
false
Copy link
Member

Choose a reason for hiding this comment

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

such a tiny typo, but such a big functional change

Copy link
Member Author

Choose a reason for hiding this comment

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

Exactly

@@ -7,7 +7,7 @@ okHttp = "4.12.0"
kronosNTP = "0.0.1-alpha11"

# Android
androidToolsPlugin = "8.6.1"
androidToolsPlugin = "8.5.2"
Copy link
Member

Choose a reason for hiding this comment

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

why are we doing downgrade?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh this shouldn't have been part of the commit, it's because I use IJ instead of AS ans IJ doesn't support the latest AGP.

@@ -23,7 +24,7 @@ import org.mockito.junit.jupiter.MockitoExtension
@ForgeConfiguration(Configurator::class)
internal class ThreadExtTest {

@Test
@RepeatedTest(16)
Copy link
Member

Choose a reason for hiding this comment

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

is this change on purpose or some debugging leftover?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is on purpose to go over all the possible states

// Given
val fakeDelay = TimeUnit.SECONDS.toNanos(forge.aLong(min = 0, max = 2))
val mockedBlock: () -> Boolean = mock()
whenever(mockedBlock.invoke()).thenAnswer { throw exception }.thenReturn(true)
Copy link
Member

Choose a reason for hiding this comment

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

probably can be shorter a bit

Suggested change
whenever(mockedBlock.invoke()).thenAnswer { throw exception }.thenReturn(true)
whenever(mockedBlock.invoke()).thenThrow(exception).thenReturn(true)

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed 👍

@xgouchet xgouchet force-pushed the xgouchet/reliability/coverage branch from 810e356 to c1f2e34 Compare September 30, 2024 08:05
@xgouchet xgouchet requested a review from 0xnm September 30, 2024 08:05
@xgouchet xgouchet merged commit 21025fd into develop Sep 30, 2024
23 checks passed
@xgouchet xgouchet deleted the xgouchet/reliability/coverage branch September 30, 2024 10:22
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