Refactor functional tests to use JSON comparison (part 1)#437
Refactor functional tests to use JSON comparison (part 1)#437
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## dev #437 +/- ##
=======================================
Coverage 96.47% 96.47%
=======================================
Files 27 27
Lines 1730 1730
=======================================
Hits 1669 1669
Misses 61 61 |
| assertExactMatch( | ||
| expected: expectedJSON, | ||
| actual: resultNetworkRequests[0], | ||
| pathOptions: | ||
| ValueTypeMatch(paths: | ||
| "events[0].xdm._id", | ||
| "events[0].xdm.timestamp", | ||
| "meta.konductorConfig.streaming.lineFeed", | ||
| "meta.konductorConfig.streaming.recordSeparator", | ||
| "xdm.identityMap.ECID[0].authenticatedState", | ||
| "xdm.identityMap.ECID[0].id", | ||
| "xdm.identityMap.ECID[0].primary"), | ||
| CollectionEqualCount(scope: .subtree)) |
There was a problem hiding this comment.
When you have multiple paths you are excluded from an exact/type match, is it worth exploring having something like:
assertTypeMatch(expected: expectedCommonKeys, actual: ...)
assertExactMatch(expected: expectedSdkConfigKeys, actual: ...)
assertCount(expected: expectedCommonKeys.count() + expectedSdkConfigKeys.count(), actual: ...)
There was a problem hiding this comment.
I can create a followup task on the iOS test utils side to explore this option of having separate assertions for each comparison option further!
There was a problem hiding this comment.
ok, let's do that if you have more examples like this. if it is just this file, current APIs should suffice
Remove redundant clearCache
Remove redundant clearCache
timkimadobe
left a comment
There was a problem hiding this comment.
Thanks for the review @emdobrin! Updated based on feedback, please let me know what you think of the latest changes
| assertExactMatch( | ||
| expected: expectedJSON, | ||
| actual: resultNetworkRequests[0], | ||
| pathOptions: | ||
| ValueTypeMatch(paths: | ||
| "events[0].xdm._id", | ||
| "events[0].xdm.timestamp", | ||
| "meta.konductorConfig.streaming.lineFeed", | ||
| "meta.konductorConfig.streaming.recordSeparator", | ||
| "xdm.identityMap.ECID[0].authenticatedState", | ||
| "xdm.identityMap.ECID[0].id", | ||
| "xdm.identityMap.ECID[0].primary"), | ||
| CollectionEqualCount(scope: .subtree)) |
There was a problem hiding this comment.
I can create a followup task on the iOS test utils side to explore this option of having separate assertions for each comparison option further!
Description
This PR updates the first portion of Edge functional tests to use the JSON comparison system. Broadly, it replaces dictionary flattening with JSON comparison. Specific changes:
assertExactMatch/assertTypeMatch- that is, the refactor should preserve the same level of strictness for the payload being testedFileManager.default.clearCache()is used,FileManager.default.removeAdobeCacheDirectory()was also added (given Core's new persistence handling)Questions for reviewers
testSendEvent_receivesResponseEventHandle_sendsResponseEvent_pairedWithTheRequestEventIdlet requestId = resultNetworkRequests[0].url.queryParam("requestId")ever be nil? Should that be strictly validated? Currently the refactor sets the fallback value to"'Related Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: