I am writing an XCTest that involves writing a file to disk. I am using an AppGroup to define the file path. This works fine running on device or simulator.
class func filePath()->URL {
guard let path = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "my.app.group.id") else {
fatalError("No File Path")
}
let filePath = path.appendingPathComponent("filename.json")
return filePath
}
… However the containerURL
doesn't return something in an XCTest environment. The test crashes.
How can I generate a temporary path that works for Unit Testing?