approvals/ApprovalTests.Swift

Received file not created

Closed this issue · 1 comments

Hello,

I'm trying the demo snippet on Xcode but the received file cannot be created.

CODE

import XCTest
import ApprovalTests_Swift
@testable import TEST_APPROVAL
class TEST_APPROVALTests: XCTestCase {
    func testList() throws {
        var names: [String] = ["Llewellyn", "James", "Dan", "Jason", "Katrina"]
        names.sort()
        try Approvals.verifyAll("", names);
    }
}

POD

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'TEST_APPROVAL' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for TEST_APPROVAL
  pod 'ApprovalTests_Swift', :git => 'https://github.com/approvals/ApprovalTests.Swift.git'
    
  target 'TEST_APPROVALTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

LOG

2020-07-07 14:18:04.615885-0400 TEST_APPROVAL[33901:6767340] Launching with XCTest injected. Preparing to run tests.
2020-07-07 14:18:04.630558-0400 TEST_APPROVAL[33901:6767340] Waiting to run tests until the app finishes launching.
2020-07-07 14:18:04.770633-0400 TEST_APPROVAL[33901:6767340] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to (null)
Test Suite 'Selected tests' started at 2020-07-07 14:18:05.094
Test Suite 'TEST_APPROVALTests.xctest' started at 2020-07-07 14:18:05.095
Test Suite 'TEST_APPROVALTests' started at 2020-07-07 14:18:05.095
Test Case '-[TEST_APPROVALTests.TEST_APPROVALTests testList]' started.
An error occured writing file:/Users/nicolas/DATA/Dev/Swift/TEST_APPROVAL/TEST_APPROVALTests/TEST_APPROVALTests.testList.received.txt
/Users/nicolas/DATA/Dev/Swift/TEST_APPROVAL/TEST_APPROVALTests/TEST_APPROVALTests.swift:18: error: -[TEST_APPROVALTests.TEST_APPROVALTests testList] : failed: caught error: "Error("Failed Approval \nApproved:/Users/nicolas/DATA/Dev/Swift/TEST_APPROVAL/TEST_APPROVALTests/TEST_APPROVALTests.testList.approved.txt \nReceived:/Users/nicolas/DATA/Dev/Swift/TEST_APPROVAL/TEST_APPROVALTests/TEST_APPROVALTests.testList.received.txt")"
Test Case '-[TEST_APPROVALTests.TEST_APPROVALTests testList]' failed (0.167 seconds).
Test Suite 'TEST_APPROVALTests' failed at 2020-07-07 14:18:05.262.
	 Executed 1 test, with 1 failure (1 unexpected) in 0.167 (0.167) seconds
Test Suite 'TEST_APPROVALTests.xctest' failed at 2020-07-07 14:18:05.263.
	 Executed 1 test, with 1 failure (1 unexpected) in 0.167 (0.168) seconds
Test Suite 'Selected tests' failed at 2020-07-07 14:18:05.263.
	 Executed 1 test, with 1 failure (1 unexpected) in 0.167 (0.169) seconds

I thought it could be a right issue, so I put the directory in 777 mode.

I tried to download the project and test it. It works when I use it inside the project itself.
But if I use POD and use it, it doesn't work. The received file is never written.

I Updated the code to display the error

ERROR=Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “approvalsTests.testList.received.txt” in the folder “approvalsTests”." UserInfo={NSFilePath=/Users/nicolas/Downloads/approvals/approvalsTests/approvalsTests.testList.received.txt, NSUnderlyingError=0x600000c58b10 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}
ERROR LD=You don’t have permission to save the file “approvalsTests.testList.received.txt” in the folder “approvalsTests”.

Thanks,
Nicolas

I find the answer.
You need to go to the test target and update the HOST setting to None.