pointfreeco / swift-snapshot-testing

📸 Delightful Swift snapshot testing.
https://www.pointfree.co/episodes/ep41-a-tour-of-snapshot-testing
MIT License
3.67k stars 556 forks source link

Support snapshot testing on iOS devices #379

Open darknoon opened 3 years ago

darknoon commented 3 years ago

Snapshot testing is great and saves an immense amount of time vs manually checking data structures or images / tests. However, some tests need to be run on actual devices for correctness.

Why

One use case is apps that make heavy use of Metal API

The way that swift-snapshot-testing tracks snapshot data currently does not work when the test app does not run where the source root is accessible (iOS, macOS sandbox). This has been mentioned before, eg https://github.com/pointfreeco/swift-snapshot-testing/issues/193 , perhaps https://github.com/pointfreeco/swift-snapshot-testing/issues/176#issuecomment-467328614

Proposed approach

Related

Going to see if I can get this working, interested to hear if anyone else is trying something similar

PauliusLiekis commented 2 years ago

Any luck with this? I can not run the tests on a simulator, thus I need to run them on a real device too...

PauliusLiekis commented 2 years ago

You can actually make it work without modifying the library. Just use verifySnapshot which takes snapshotDirectory as an argument. Then all you have to do is place your snapshot images in a folder that gets packed into the bundle and then specify correct path for snapshotDirectory. That usually means that you can not keep your reference images in the __Snapshots__ folders next to the source, but I was ok with moving them all into one folder with some subfolders.

winstondu commented 2 years ago

@darknoon , any update?

Fl0p commented 5 months ago

Bump