iOS Development

ios – Optimizing Picture Dealing with in Swift Snapshot Testing

Spread the love


I’m utilizing the Swift-Snapshot-Testing library (https://github.com/pointfreeco/swift-snapshot-testing) for snapshot testing in an iOS mission and going through a few challenges associated to picture administration and comparability.

  1. Managing Baseline and New Failed Photos:

In my snapshot assessments, I initially set isRecording to true to seize the baseline picture. For instance:

func testExampleSnapshot() {
    let view = CustomView(viewModel: .fixture()).background(Coloration.white)
    let controller = UIHostingController(rootView: view)
    controller.view.backgroundColor = .systemYellow

    isRecording = true
    SnapshotTesting.diffTool = "ksdiff"
    assertSnapshot(matching: controller, as: .picture)
}

This works effectively for creating the baseline picture. Nonetheless, when a change within the view causes the snapshot take a look at to fail, the newly generated failed picture is saved in a unique location from the baseline picture. This necessitates a guide search to seek out and evaluate the brand new failed picture, which is sort of time-consuming.

Is there a extra streamlined course of for this? Ideally, I would like the brand new failed picture to be routinely saved in the identical folder because the baseline picture. This could permit for simpler comparability utilizing instruments like SourceTree, with out the necessity to toggle isRecording between true and false for updating the baseline. Any ideas for a extra environment friendly strategy can be enormously appreciated.

  1. Organizing Snapshot Photos:

At the moment, the baseline pictures are saved in a number of folders throughout the snapshot folder, corresponding to every take a look at file. This leads to quite a few directories containing these pictures.

Is there a extra organized approach to deal with this? Maybe storing all pictures in a single folder, categorized by take a look at class title or perform, may be extra manageable. I am looking for recommendation on the most effective practices for effectively organizing these snapshot pictures in an expert setup.

Any insights or ideas on these points can be enormously appreciated!

Leave a Reply

Your email address will not be published. Required fields are marked *