Add comprehensive unit tests for NewRelicVideoCore#92
Add comprehensive unit tests for NewRelicVideoCore#92
Conversation
a70918e to
b085127
Compare
| } | ||
|
|
||
| @Test | ||
| public void testTokenEndpointForUSRegion() { |
There was a problem hiding this comment.
Consider parameterized tests for similar scenarios .
@valuesource(strings = {"US", "EU", "AP"})
| } | ||
|
|
||
| @Test | ||
| public void testTokenEndpointForEURegion() { |
There was a problem hiding this comment.
Consider parameterized tests for similar scenarios . @valuesource(strings = {"US", "EU", "AP"})
| } | ||
|
|
||
| @Test | ||
| public void testTokenEndpointForAPRegion() { |
There was a problem hiding this comment.
Consider parameterized tests for similar scenarios . @valuesource(strings = {"US", "EU", "AP"})
| public class DeviceFormTest { | ||
|
|
||
| @Test | ||
| public void testEnumValues() { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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++) { |
There was a problem hiding this comment.
Add helper methods - create events with specific sizes
| // Now start again - this should trigger foreground transition | ||
| observer.onActivityStarted(mockActivity); | ||
|
|
||
| verify(mockScheduler, atLeastOnce()).resume(anyBoolean()); |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
follow the same pattern in naming convention
| observer.onActivityStarted(mockActivity); | ||
|
|
||
| // Should not throw exception | ||
| verify(mockScheduler, atLeastOnce()).resume(anyBoolean()); |
There was a problem hiding this comment.
Add ArgumentCaptor tests - verify boolean values passed to resume()
| */ | ||
| @RunWith(RobolectricTestRunner.class) | ||
| @Config(sdk = 28, manifest = Config.NONE) | ||
| public class NRVideoLifecycleObserverTest { |
There was a problem hiding this comment.
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 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. |
Added comprehensive unit test suite for NewRelicVideoCore package, achieving 66% instruction coverage with 670 isolated unit tests across 11 core packages.
Verification details:



