Skip to content

Test helper parity and method renaming#405

Merged
timkimadobe merged 7 commits intoadobe:devfrom
timkimadobe:test-helper-parity2
Sep 27, 2023
Merged

Test helper parity and method renaming#405
timkimadobe merged 7 commits intoadobe:devfrom
timkimadobe:test-helper-parity2

Conversation

@timkimadobe
Copy link
Copy Markdown
Contributor

@timkimadobe timkimadobe commented Sep 22, 2023

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

  • 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.

# Conflicts:
#	Tests/TestUtils/MockNetworkService.swift
#	Tests/TestUtils/NetworkRequestHelper.swift
#	Tests/TestUtils/RealNetworkService.swift
#	Tests/UpstreamIntegrationTests/UpstreamIntegrationTests.swift
Rename setExpectationForNetworkRequest to be more Swifty

# Conflicts:
#	Tests/TestUtils/MockNetworkService.swift
Rename timeout to expectationTimeout to clarify timeout intent
Refactor logic to remove waiting in getResponses, and rely on await in assertAllNetworkRequestExpectations

# Conflicts:
#	Tests/TestUtils/MockNetworkService.swift
#	Tests/TestUtils/NetworkRequestHelper.swift
#	Tests/TestUtils/RealNetworkService.swift
#	Tests/UpstreamIntegrationTests/UpstreamIntegrationTests.swift
Update method documentation
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 22, 2023

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           

@timkimadobe timkimadobe merged commit 2053d90 into adobe:dev Sep 27, 2023
@timkimadobe timkimadobe deleted the test-helper-parity2 branch September 29, 2023 22:42
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