Skip to content

Split up BackendTests into individual smaller test files for each NetworkOperation#1365

Merged
NachoSoto merged 1 commit into
mainfrom
separate-backend-tests
Mar 9, 2022
Merged

Split up BackendTests into individual smaller test files for each NetworkOperation#1365
NachoSoto merged 1 commit into
mainfrom
separate-backend-tests

Conversation

@NachoSoto

@NachoSoto NachoSoto commented Mar 7, 2022

Copy link
Copy Markdown
Contributor

Before this change, BackendTests was an unmaintainable 1929 lines.
Now we have much smaller tests for each type of operation:

  • BackendCreateAliasTests.swift: 165
  • BackendGetCustomerInfoTests.swift: 169
  • BackendGetIntroEligibilityTests.swift: 192
  • BackendGetOfferingsTests.swift: 208
  • BackendLoginTests.swift: 335
  • BackendPostAttributionDataTests.swift: 42
  • BackendPostOfferForSigningTests.swift: 262
  • BackendPostReceiptDataTests.swift: 700
  • BackendPostSubscriberAttributesTests.swift: 35

Additionally, each test file only has helpers and dummy data relevant for those operations, instead of all combined into the much larger file.

The createClient override was necessary to make sure that the snapshots were split for each test class, which also makes navigating these much easier:

Screen Shot 2022-03-07 at 14 56 52

@NachoSoto NachoSoto requested a review from a team March 7, 2022 22:57
@@ -1,6 +0,0 @@
{

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.

This was really funny. This test ensures that only ONE request is made thanks to caching. Somehow we ran this test when that implementation was broken, which created this second request snapshot. After cleaning up the snapshots for the separate folders, this was the only change: this file now is removed because the implementation only makes one request!

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.

Omg that's incredible

@NachoSoto NachoSoto force-pushed the separate-backend-tests branch from cd4bf57 to 9d8a36f Compare March 8, 2022 00:16
@NachoSoto NachoSoto force-pushed the combined-mock-http-clients branch from 49a5c46 to 96b69f1 Compare March 8, 2022 20:56
Base automatically changed from combined-mock-http-clients to main March 8, 2022 21:05
…NetworkOperation`

Before this change, `BackendTests` was an unmaintainable 1929 lines.
Now we have much smaller tests for each type of operation:

- `BackendCreateAliasTests.swift`:              165
- `BackendGetCustomerInfoTests.swift`:          169
- `BackendGetIntroEligibilityTests.swift`:      192
- `BackendGetOfferingsTests.swift`:             208
- `BackendLoginTests.swift`:                    335
- `BackendPostAttributionDataTests.swift`:      42
- `BackendPostOfferForSigningTests.swift`:      262
- `BackendPostReceiptDataTests.swift`:          700
- `BackendPostSubscriberAttributesTests.swift`: 35
- `BaseBackendTest.swift`:                      83
@NachoSoto NachoSoto merged commit 4273e39 into main Mar 9, 2022
@NachoSoto NachoSoto deleted the separate-backend-tests branch March 9, 2022 20:58
NachoSoto added a commit that referenced this pull request May 31, 2022
`PurchasesTests.swift` is nearly 3000 lines. This is the first step towards making separate smaller files like I did with `BackendTests.swift` in #1365.
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.

3 participants