Fix #2983: Fix self-referential test assertions in serialization round-trip tests#3242
Merged
Merged
Conversation
…d-trip tests Root cause: 11 test files used assertThat(result).isEqualTo(result) instead of actually comparing the deserialized result against the original input, making the tests tautological (always passing regardless of correctness). Changes: - Replace self-referential assertions with JSON string comparison - assertThat(result.toJson().toString()).isEqualTo(json) validates that JSON survives a full round-trip through fromJson()/toJson() Tests: 11 test files fixed across 4 modules (core, rum, logs, trace) Verified: core (PASS), logs (PASS), trace (PASS), rum (BLOCKED by pre-existing compile error) Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This comment has been minimized.
This comment has been minimized.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3242 +/- ##
===========================================
- Coverage 71.40% 71.39% -0.01%
===========================================
Files 938 938
Lines 34667 34667
Branches 5874 5874
===========================================
- Hits 24753 24749 -4
- Misses 8263 8272 +9
+ Partials 1651 1646 -5 🚀 New features to boost your workflow:
|
mariusc83
marked this pull request as ready for review
March 10, 2026 09:32
0xnm
approved these changes
Mar 11, 2026
hamorillo
approved these changes
Mar 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Fixes #2983: Some tests always pass due to wrong assertion
GitHub Issue: #2983
Root Cause Analysis
All 11 serialization round-trip tests used self-referential assertions (
assertThat(result).isEqualTo(result)) instead of comparing the deserialized result against the original input. This made the tests tautological — they always passed regardless of whethertoJson()/fromJson()worked correctly.Changes
Changed all 11 test assertions from
assertThat(result).isEqualTo(result)toassertThat(result.toJson().toString()).isEqualTo(json), which validates that JSON data survives a full round-trip throughfromJson()/toJson().The JSON string comparison approach was chosen over object equality (
isEqualTo(event)) because:SpanEvent.Span) are notdata classand lackequals()implementationsFiles Changed
ActionEventTest.ktErrorEventTest.ktLongTaskEventTest.ktResourceEventTest.ktViewEventTest.ktTelemetryDebugEventTest.ktTelemetryErrorEventTest.ktNetworkInfoTest.ktUserInfoTest.ktLogEventTest.ktSpanEventTest.ktTest Coverage
RumVitalAppLaunchEventredeclaration) ondevelop, unrelated to this changeInvestigation Log
Issue Analysis
The issue reporter identified that multiple test files contained
assertThat(result).isEqualTo(result)which always passes. This was confirmed across 11 files in 4 modules (2 more than originally reported).Reproduction
All 11 affected files follow the same pattern: forge a random event, serialize to JSON, deserialize, and compare. The self-referential assertion never catches serialization bugs.
Fix Approach
assertThat(result).isEqualTo(event)— this revealed real serialization differences (non-data-class types, JSON type coercion)equals()