Skip to content

Refactor unit test cases to use JSON comparison (part 2)#436

Merged
timkimadobe merged 30 commits intoadobe:devfrom
timkimadobe:refactor-for-json-comparison3
Jan 8, 2024
Merged

Refactor unit test cases to use JSON comparison (part 2)#436
timkimadobe merged 30 commits intoadobe:devfrom
timkimadobe:refactor-for-json-comparison3

Conversation

@timkimadobe
Copy link
Copy Markdown
Contributor

@timkimadobe timkimadobe commented Dec 15, 2023

Note

This is the second part in a multi-part series of PRs that will refactor existing Edge extension unit and functional tests to use the JSON comparison tool from AEPTestUtils
See part 1: #434 (Please merge part 1 first, as this branch incorporates its changes.)

Description

This PR refactors the rest of the Edge extension unit tests to use the test helper utilities from AEPTestUtils

Questions for reviewers

In RequestBuilderTests.swift
testGetPayloadWithExperienceEvents_withEventXdm_verifyEventId_verifyTimestamp
and
testGetPayloadWithExperienceEvents_withQuery_responseContainsQuery

  1. Was it intended to not do a count check? There was no element count check post-flattening (pre-migration). To mirror this non-strict element check the JSON comparison currently does an extensible comparison instead of strict equality.

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

…dsNetworkRequest_returnsTrue

testProcessHit_experienceEvent_withDatastreamOverrideSet_sendsNetworkRequest_returnsTrue change intent:
1. Refactor existing mock network service method usage to AEPTestUtils MockNetworkService, which explicitly requires URL
    a. Has the downstream effect of more strictly validating the request
2. Take advantage of new functionality in mockNetworkService.assertAllNetworkRequestExpectations to validate both:
    a. Expected events
    b. No unexpected events (toggleable)
3. Remove mock response from test case setup since it is the same as the mock response set in helper assertProcessHit
…urnsTrue

Remove mock response from test case setup since it is the same as the mock response set in helper assertProcessHit
To take advantage of new functionality in mockNetworkService.assertAllNetworkRequestExpectations to validate:
    a. Expected events
    b. No unexpected events (toggleable)
    c. No requests sent out (no expectations + no unexpected events allowed)
Move encoder to top level of class for reuse
@timkimadobe timkimadobe changed the base branch from main to dev December 15, 2023 05:05
Copy link
Copy Markdown
Contributor

@kevinlind kevinlind left a comment

Choose a reason for hiding this comment

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

Looks good, though you'll need to fix the build failures before merging.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 8, 2024

Codecov Report

Merging #436 (755f323) into dev (2c9403f) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #436   +/-   ##
=======================================
  Coverage   96.47%   96.47%           
=======================================
  Files          27       27           
  Lines        1730     1730           
=======================================
  Hits         1669     1669           
  Misses         61       61           

@timkimadobe timkimadobe merged commit 6a3563a into adobe:dev Jan 8, 2024
@timkimadobe timkimadobe deleted the refactor-for-json-comparison3 branch January 8, 2024 22:52
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.

2 participants