Skip to content

Add comprehensive unit tests for NewRelicVideoCore#92

Open
arkaza-nr wants to merge 6 commits intomasterfrom
user/arkazakumari/ut-android
Open

Add comprehensive unit tests for NewRelicVideoCore#92
arkaza-nr wants to merge 6 commits intomasterfrom
user/arkazakumari/ut-android

Conversation

@arkaza-nr
Copy link
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
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
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
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
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
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
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
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
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
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
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
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
Collaborator

@copilot

Copy link

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.

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.

3 participants

Comments