adobe / aepsdk-edge-ios

Adobe Experience Platform Edge Network mobile extension in Swift
Apache License 2.0
13 stars 24 forks source link

Test helper parity and method renaming #405

Closed timkimadobe closed 1 year ago

timkimadobe commented 1 year ago

Description

This PR:

  1. Updates the RealNetworkService getResponse method to not include an await in the logic, instead returning results immediately, and relying on assertAllNetworkRequestExpectations to perform awaits
  2. Adds method documentation to a lot of the test helper methods, and standardizes language
    • Removes specific class names from top level method descriptions, instead placing them in the param descriptions when needed - intent is to explain what the method does in a general way
  3. Renames a lot of methods to be more Swifty and hopefully more intuitive; since these methods are already strongly tied to the Mock/RealNetworkService, a lot of the redundant networkRequest method and param names can probably be omitted without affecting clarity of intent.

MockNetworkService

Before After
getMockResponseFor(networkRequest:) getMockResponse(for:)
setMockResponseFor(networkRequest:responseConnection:) setMockResponse(for:responseConnection:)
setMockResponseFor(url:httpMethod:responseConnection:) setMockResponse(url:httpMethod:responseConnection:)

NetworkRequestHelper

Before After
getSentNetworkRequestsMatching(networkRequest:) getSentRequests(matching:)
setResponseFor(networkRequest:responseConnection:) setResponse(for:responseConnection:)
getResponseFor(networkRequest:) getResponse(for:)
setExpectationForNetworkRequest(networkRequest:...) setExpectation(for:...)
timeout expectationTimeout

getNetworkRequestsWith and awaitRequest parameter timeout -> expectationTimeout (as this timeout only applies if there is already an expectation set on the network request, if there is no expectation this timeout value is not used and the default timeout is used instead)

RealNetworkService

Before After
getResponseFor(networkRequest:timeout:) getResponse(for:)
setExpectationForNetworkRequest(networkRequest:...) setExpectation(for:...)

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

Checklist:

codecov[bot] commented 1 year ago

Codecov Report

Merging #405 (06a183f) into dev (285aeb9) will not change coverage. The diff coverage is n/a.

@@           Coverage Diff           @@
##              dev     #405   +/-   ##
=======================================
  Coverage   96.77%   96.77%           
=======================================
  Files          27       27           
  Lines        1671     1671           
=======================================
  Hits         1617     1617           
  Misses         54       54