Brightify / Cuckoo

Boilerplate-free mocking framework for Swift!
MIT License
1.67k stars 175 forks source link

Not able to initialise Mock Object #487

Closed gopalakrishnan2547 closed 7 months ago

gopalakrishnan2547 commented 9 months ago

I followed these steps: Swift Package Manager In Xcode, navigate in menu: File > Swift Packages > Add Package Dependency Add https://github.com/Brightify/Cuckoo.git For the Dependency Rule, Select "Up to Next Major" with 1.10.3. Click Add Package. On the 'Choose Package Products for Cuckoo' dialog, under 'Add to Target', please ensure you select your Test target as it will not compile on the app target. Click Add Package. When you're all set, use the same Run script phase as above and replace

"${PODS_ROOT}/Cuckoo/run" with

"${BUILD_DIR%/Build/*}/SourcePackages/checkouts/Cuckoo/run"

I can import the Cuckoo framework

but when i try to create mockobject using Mock prefix i get "Cannot find 'MockAPIService' in scope" error.

this my sample code class HomeScreenVM { var apiService: APIService = APIService() override init() { super.init() apiService.getStatus() } }

class APIService { func getStatus() -> Bool{ return true } }

this is my test case code func test_ScreenVM_isShowPopup_shouldTrue(){ var vm = HomeScreenVM() let mockAPIService = MockAPIService() XCTAssertTrue(vm.isShowPopup) }

Screenshot 2024-02-20 at 6 24 23 PM
MatyasKriz commented 9 months ago

The steps require you to replace the line "${PODS_ROOT}/Cuckoo/run", so it's redundant in the run script build phase. Does the error still occur when you remove it?