Turning on isRecording
outside of an individual XCTestCase
#457
Replies: 2 comments 1 reply
-
To make sure that this happens before any test runs, you could create a It could look like this: @objc(PrincipalClass)
class PrincipalClass: NSObject {
override init() {
isRecording = true
}
} |
Beta Was this translation helpful? Give feedback.
-
When you run test using Do you think this would be something to add in a PR? import SnapshotTesting
import XCTest
import InlineSnapshotTesting
/// Convenience that looks for an environment variable SNAPSHOT_TESTING_UPDATE_TESTS that can be set to true in order to
/// have the tests update from commandline
open class XCTestCaseSnapshot: XCTestCase {
open override class func setUp() {
super.setUp()
SnapshotTesting.diffTool = "ksdiff"
InlineSnapshotTesting.diffTool = SnapshotTesting.diffTool
let isRecording = Bool(ProcessInfo.processInfo.environment["SNAPSHOT_TESTING_UPDATE_TESTS"] ?? "false") ?? false
SnapshotTesting.isRecording = isRecording
InlineSnapshotTesting.isRecording = isRecording
}
} Running the tests from cli would then be
Let me know what you think? |
Beta Was this translation helpful? Give feedback.
-
Is there any way currently to set
isRecording
outside of an individualXCTestCase
subclass? For example, say I make a change that I know is going to affect a whole bunch of snapshots, currently I would need to find all those test files and setisRecording
totrue
on all of them (or use therecording
parameter).I would like to just be able to turn something on in say an environment variable or in the
AppDelegate
or someplace else.I would also prefer to do this without making a subclass of
XCTestCase
or adding a protocol, or making my own version ofassertSnapshot
all of which would require people to remember to use them.This is especially useful for whenever there's an iOS update and all your snapshots need to be updated.
Beta Was this translation helpful? Give feedback.
All reactions