adobe / aepsdk-core-ios

Adobe Experience Platform Mobile Core SDK in Swift
Apache License 2.0
24 stars 40 forks source link

Restructure AEPTestUtils internal frameworks #1082

Closed timkimadobe closed 4 days ago

timkimadobe commented 5 days ago

Description

This PR updates the Core project structure to separate the internal frameworks AEPServicesMocks and AEPCoreMocks entirely; dependence on AEPServicesMocks inside AEPCoreMocks files (via import AEPServicesMocks) were causing usage issues for dependent projects trying to use AEPTestUtils, since AEPServicesMocks doesn't exist outside of the Core project.

AEPServicesMocks Compile Sources contain all the local Services mock files and AEPTestUtils files that only depend on AEPServices AEPCoreMocks Compile Sources contain all of AEPServicesMocks + local Core mock files and AEPTestUtils files that depend on Core

Also adds new Core test API to reset the SDK, and marks the EventHub reset API as deprecated:

public extension MobileCore {
    /// Resets the SDK by shutting down and resetting the EventHub.
    static func resetSDK() {
        EventHub.shared.shutdown()
        EventHub.shared = EventHub()
    }
}

extension EventHub {
    @available(*, deprecated, renamed: "MobileCore.resetSDK()", message: "Avoid using EventHub APIs directly. Use MobileCore.resetSDK() instead.")
    public static func reset() {
        shared = EventHub()
    }
}

Imports have also been cleaned up and organized:

<external frameworks, alphabetized>

<internal frameworks, alphabetized>

ex:

import XCTest

@testable import AEPCore
@testable import AEPCoreMocks
import AEPIdentity
import AEPLifecycle
@testable import AEPServices
import AEPSignal

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

Checklist:

praveek commented 5 days ago

@timkimadobe How about organizing the imports as follows:

import Foundation
import XCTest

// AEP module imports
import AEPIdentity
import AEPLifecycle
import AEPSignal

// Testable imports
@testable import AEPCore
@testable import AEPCoreMocks
@testable import AEPServices
praveek commented 5 days ago

Could you also update the Test Utils README.md to clarify what targets a new file should be added to between AEPServiceMocks and AEPCoreMocks?

timkimadobe commented 5 days ago

Thanks for the review @praveek! Updated based on feedback