Skip to content

Add comprehensive unit tests for NewRelicVideoCore#92

Merged
ametku merged 8 commits intorelease/16MAR2026from
user/arkazakumari/ut-android
Mar 16, 2026
Merged

Add comprehensive unit tests for NewRelicVideoCore#92
ametku merged 8 commits intorelease/16MAR2026from
user/arkazakumari/ut-android

Conversation

@arkaza-nr
Copy link
Copy Markdown
Contributor

Added comprehensive unit test suite for NewRelicVideoCore package, achieving 66% instruction coverage with 670 isolated unit tests across 11 core packages.

Verification details:
image
image
image
image

@arkaza-nr arkaza-nr force-pushed the user/arkazakumari/ut-android branch from a70918e to b085127 Compare January 15, 2026 07:06
@swatijha23 swatijha23 self-requested a review February 5, 2026 09:32
Copy link
Copy Markdown
Collaborator

@swatijha23 swatijha23 left a comment

Choose a reason for hiding this comment

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

@arkaza-nr fix the build failure

}

@Test
public void testTokenEndpointForUSRegion() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Consider parameterized tests for similar scenarios .
@valuesource(strings = {"US", "EU", "AP"})

}

@Test
public void testTokenEndpointForEURegion() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Consider parameterized tests for similar scenarios . @valuesource(strings = {"US", "EU", "AP"})

}

@Test
public void testTokenEndpointForAPRegion() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Consider parameterized tests for similar scenarios . @valuesource(strings = {"US", "EU", "AP"})

public class DeviceFormTest {

@Test
public void testEnumValues() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Replace hardcoded enum count assertions with tests that verify the presence of specific required enum values

List valuesList = Arrays.asList(values);
assertTrue(valuesList.contains(DeviceForm.SMALL));
assertTrue(valuesList.contains(DeviceForm.NORMAL));
assertTrue(valuesList.contains(DeviceForm.LARGE));
assertTrue(valuesList.contains(DeviceForm.XLARGE));
assertTrue(valuesList.contains(DeviceForm.TABLET));
assertTrue(valuesList.contains(DeviceForm.TV));
assertTrue(valuesList.contains(DeviceForm.UNKNOWN));

boolean isTV = deviceInfo.isTV();

// Just verify it returns a boolean
assertTrue(isTV || !isTV);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Avoid assertions that are always true
assertFalse(isTV);

@Test
public void testPriorityPreservationWithLargeDataset() {
// Add 100 events of each type
for (int i = 0; i < 100; i++) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Add helper methods - create events with specific sizes

// Now start again - this should trigger foreground transition
observer.onActivityStarted(mockActivity);

verify(mockScheduler, atLeastOnce()).resume(anyBoolean());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

atLeastOnce() doesn't distinguish between calls made during background vs foreground transitions. The test passes even if the behavior is wrong. Use times() with proper reset between phases.

}

@Test
public void testOnActivitySaveInstanceState_TriggersEmergencyBackup() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

follow the same pattern in naming convention

observer.onActivityStarted(mockActivity);

// Should not throw exception
verify(mockScheduler, atLeastOnce()).resume(anyBoolean());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Add ArgumentCaptor tests - verify boolean values passed to resume()

*/
@RunWith(RobolectricTestRunner.class)
@Config(sdk = 28, manifest = Config.NONE)
public class NRVideoLifecycleObserverTest {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Add state verification tests - verify activity counters work correctly
Add concurrency tests - test concurrent activity starts/stops
Add edge case tests - rapid state changes, negative counters
Test platform-specific behavior - verify mobile vs TV differences
Remove custom assertNotNull - use JUnit's built-in assertion

@swatijha23
Copy link
Copy Markdown
Collaborator

@copilot

Copy link
Copy Markdown

Copilot AI commented Feb 5, 2026

@swatijha23 I've opened a new pull request, #114, to work on those changes. Once the pull request is ready, I'll request review from you.

@ametku ametku changed the base branch from master to release/16MAR2026 March 16, 2026 10:22
@ametku ametku merged commit 0d724a9 into release/16MAR2026 Mar 16, 2026
5 checks passed
@ametku
Copy link
Copy Markdown
Contributor

ametku commented Mar 16, 2026

merging the changes release branch after verifying all test cases are passing ✅

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