Skip to content

JSON comparison parity - test cases#402

Merged
timkimadobe merged 5 commits intoadobe:feature/json-comparison-parityfrom
timkimadobe:json-comparison-tests2
Sep 29, 2023
Merged

JSON comparison parity - test cases#402
timkimadobe merged 5 commits intoadobe:feature/json-comparison-parityfrom
timkimadobe:json-comparison-tests2

Conversation

@timkimadobe
Copy link
Copy Markdown
Contributor

@timkimadobe timkimadobe commented Sep 20, 2023

Description

This PR splits test coverage into parameterized and unit test cases, and provides more comprehensive, systematic coverage of the JSON comparison feature. It brings the iOS implementation in line with the latest Android changes.

Please see adobe/aepsdk-edge-android#79 for reference, specifically:

Question for reviewers:
The parameterized tests use XCTContext.runActivity to create separate test cases, however errors in Xcode are presented differently; now the left side panel Test navigator that shows the individual test cases serves as an overall pass/fail indicator for the whole group of parameterized tests - is this an acceptable change? Are there any other format or logging updates that are required in this case?

Screenshot 2023-09-19 at 5 01 58 PM

and individual parameterized test cases can be seen in the Report navigator.

Screenshot 2023-09-19 at 5 03 38 PM

The following is an example of the console output that would be seen in Xcode and CI systems:

Test Suite 'Selected tests' started at 2023-09-19 16:59:44.966
Test Suite 'UpstreamIntegrationTests.xctest' started at 2023-09-19 16:59:44.967
Test Suite 'AnyCodableAssertsParameterizedTests' started at 2023-09-19 16:59:44.967
Test Case '-[UpstreamIntegrationTests.AnyCodableAssertsParameterizedTests testValueMatching]' started.
.../aepsdk-edge-ios/Tests/UpstreamIntegrationTests/AnyCodableAssertsParameterizedTests.swift:31: error: -[UpstreamIntegrationTests.AnyCodableAssertsParameterizedTests testValueMatching] : XCTAssertEqual failed: ("1") is not equal to ("2") - Key path: 
.../aepsdk-edge-ios/Tests/UpstreamIntegrationTests/AnyCodableAssertsParameterizedTests.swift:32: error: -[UpstreamIntegrationTests.AnyCodableAssertsParameterizedTests testValueMatching] : XCTAssertEqual failed: ("Optional(1)") is not equal to ("Optional(2)") - Key path: 
.../aepsdk-edge-ios/Tests/UpstreamIntegrationTests/AnyCodableAssertsParameterizedTests.swift:31: error: -[UpstreamIntegrationTests.AnyCodableAssertsParameterizedTests testValueMatching] : XCTAssertEqual failed: ("5.0") is not equal to ("2.0") - Key path: 
.../aepsdk-edge-ios/Tests/UpstreamIntegrationTests/AnyCodableAssertsParameterizedTests.swift:32: error: -[UpstreamIntegrationTests.AnyCodableAssertsParameterizedTests testValueMatching] : XCTAssertEqual failed: ("Optional(5.0)") is not equal to ("Optional(2.0)") - Key path: 
.../aepsdk-edge-ios/Tests/UpstreamIntegrationTests/AnyCodableAssertsParameterizedTests.swift:31: error: -[UpstreamIntegrationTests.AnyCodableAssertsParameterizedTests testValueMatching] : XCTAssertEqual failed: ("true") is not equal to ("false") - Key path: 
.../aepsdk-edge-ios/Tests/UpstreamIntegrationTests/AnyCodableAssertsParameterizedTests.swift:32: error: -[UpstreamIntegrationTests.AnyCodableAssertsParameterizedTests testValueMatching] : XCTAssertEqual failed: ("Optional(true)") is not equal to ("Optional(false)") - Key path: 
.../aepsdk-edge-ios/Tests/UpstreamIntegrationTests/AnyCodableAssertsParameterizedTests.swift:31: error: -[UpstreamIntegrationTests.AnyCodableAssertsParameterizedTests testValueMatching] : XCTAssertEqual failed: ("a") is not equal to ("b") - Key path: 
.../aepsdk-edge-ios/Tests/UpstreamIntegrationTests/AnyCodableAssertsParameterizedTests.swift:32: error: -[UpstreamIntegrationTests.AnyCodableAssertsParameterizedTests testValueMatching] : XCTAssertEqual failed: ("Optional("a")") is not equal to ("Optional("b")") - Key path: 
Test Case '-[UpstreamIntegrationTests.AnyCodableAssertsParameterizedTests testValueMatching]' failed (0.125 seconds).
Test Suite 'AnyCodableAssertsParameterizedTests' failed at 2023-09-19 16:59:45.093.
     Executed 1 test, with 8 failures (0 unexpected) in 0.125 (0.126) seconds
Test Suite 'UpstreamIntegrationTests.xctest' failed at 2023-09-19 16:59:45.093.
     Executed 1 test, with 8 failures (0 unexpected) in 0.125 (0.127) seconds
Test Suite 'Selected tests' failed at 2023-09-19 16:59:45.093.
     Executed 1 test, with 8 failures (0 unexpected) in 0.125 (0.127) seconds
Program ended with exit code: 1

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.

Splits coverage into parameterized and special case tests, and update provides more comprehensive systematic coverage
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 20, 2023

Codecov Report

Merging #402 (1b1456e) into feature/json-comparison-parity (d7e511e) will not change coverage.
The diff coverage is n/a.

@@                       Coverage Diff                       @@
##           feature/json-comparison-parity     #402   +/-   ##
===============================================================
  Coverage                           96.77%   96.77%           
===============================================================
  Files                                  27       27           
  Lines                                1671     1671           
===============================================================
  Hits                                 1617     1617           
  Misses                                 54       54           

… boolean cases

Update index helper comments based on changed values
Copy link
Copy Markdown
Contributor Author

@timkimadobe timkimadobe left a comment

Choose a reason for hiding this comment

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

Thanks so much for the review @addb! Updated based on feedback

@timkimadobe timkimadobe requested a review from addb September 20, 2023 23:44
@timkimadobe timkimadobe requested a review from addb September 21, 2023 23:04
(expected: #"{ "\\": 1 }"#, actual: #"{ "\\": 1 }"#), // Backslash
(expected: #"{ "\\\\": 1 }"#, actual: #"{ "\\\\": 1 }"#), // Double backslash
(expected: #"{ ".": 1 }"#, actual: #"{ ".": 1 }"#), // Dot
(expected: #"{ "k.1.2.3": 1 }"#, actual: #"{ "k.1.2.3": 1 }"#), // Dat in key
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

typo in comment
// Dot in key

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you! Fixed

(path: "[*]", expected: true, actual: false, format: { #"[\#($0)]"# }),
]
let testCases = rawCases.map { tuple in
let expectedAnyCodable: AnyCodable? = getAnyCodable(tuple.format(tuple.expected))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For all related tests.
nit For Readability: can we also create actualAnyCodable:

let actualAnyCodable: AnyCodable? = getAnyCodable(tuple.format(tuple.actual))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you! I think this is a great change, updated all test cases that have inline actual creation

Copy link
Copy Markdown
Contributor

@addb addb left a comment

Choose a reason for hiding this comment

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

LGTM. Just few minor comments.

Copy link
Copy Markdown
Contributor Author

@timkimadobe timkimadobe left a comment

Choose a reason for hiding this comment

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

Thanks so much for the review @addb! Updated based on feedback

(expected: #"{ "\\": 1 }"#, actual: #"{ "\\": 1 }"#), // Backslash
(expected: #"{ "\\\\": 1 }"#, actual: #"{ "\\\\": 1 }"#), // Double backslash
(expected: #"{ ".": 1 }"#, actual: #"{ ".": 1 }"#), // Dot
(expected: #"{ "k.1.2.3": 1 }"#, actual: #"{ "k.1.2.3": 1 }"#), // Dat in key
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you! Fixed

(path: "[*]", expected: true, actual: false, format: { #"[\#($0)]"# }),
]
let testCases = rawCases.map { tuple in
let expectedAnyCodable: AnyCodable? = getAnyCodable(tuple.format(tuple.expected))
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you! I think this is a great change, updated all test cases that have inline actual creation

@timkimadobe timkimadobe merged commit b490a4c into adobe:feature/json-comparison-parity Sep 29, 2023
@timkimadobe timkimadobe deleted the json-comparison-tests2 branch September 29, 2023 22:44
@timkimadobe timkimadobe mentioned this pull request Sep 29, 2023
10 tasks
timkimadobe added a commit that referenced this pull request Oct 12, 2023
* JSON comparison parity (utility only) (#401)

* Remove custom helper enums and refactor usages

Update documentation and code logic to match Android implementation

* Apply lint autocorrect

* Revert "Apply lint autocorrect"

This reverts commit 7f38d19.

* Apply lint autocorrect

* Reduce wordiness of file and line param descriptions

* Update documentation null to nil

* Update file and line param descriptions

* Add method documentation to all helper methods

Update param name of extractArrayStyleComponents to be more intuitively descriptive

* JSON comparison parity - test cases (#402)

* Achieves parity with the Android Edge test setup for JSON comparison

Splits coverage into parameterized and special case tests, and update provides more comprehensive systematic coverage

* Add additional test cases to validate type mismatch detection and all boolean cases

Update index helper comments based on changed values

* Update failure cases to check for unintended type casting

* Fix comment typo

* Extract inline actual AnyCodable creation to separate line for clarity

* Refactor wildcard index logic (#416)

* Refactor wildcard index access to flatten logic since different condition and replacement groups are not needed

* Reformat method documentation to bring them all together

* Rename variables to better reflect what each one stores

* Refactor wildcard array index extraction to strictly validate format

Extract wildcard array index extraction logic into separate function
Update usages, test cases, and method documentation

* Update test failure message to include example format

* Rename `extractArrayStyleComponents` and update method docs (#418)

* Rename the extractArrayStyleComponents -> extractArrayFormattedComponents to better reflect actual behavior

Update method documentation to reflect the rename and to better explain the logic

* Update parameter description

* Update method description

* Include information about removing escape character
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