New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Continuous Integration #438
Comments
You would generate the reference screenshots in your branch work and store them. The CI doesn't generate them. It only compares them. |
🤯😟 |
@zablaetna could you please elaborate from this starting point? I am genuinely confused and I would appreciate your help. import SnapshotTesting
import XCTest
class MyViewControllerTests: XCTestCase {
func testMyViewController() {
let vc = MyViewController()
assertSnapshot(matching: vc, as: .image)
}
} |
You shouldn't be generating the snapshots on CI. Those should be getting generated and committed. Run your UI tests and have them generate naturally. Then commit those once you do a visual inspection. After that, CI runs and does the comparisons. Maybe I'm not following exactly what you're asking? |
Hi @zablaetna Ok so I have taken the liberty of reading the code. There is some annotation in place that says, as follows:
I can see that there is a directory parameter that I can pass in, which will allow me to specify where I want the generated images to be saved. Yes? If I specify a location within the scope of my project, then the images will be indexed by my git repository and I can upload the images to CI. At which point the CI will compare them, yes? |
Correct. |
Now do you see the problem? @zablaetna |
Nope. |
The problem: I had to ask the community questions and read the code itself, to learn about this API. I think the readme should have one or two sentences that highlights this particular API and maybe some simple guidance on where to stash the images. It's the little things that matter. Developers love shortcuts that can save them brain energy right? Especially when we work 9 to 5 doing code. We love shortcuts, from the small ones like a keyboard hotkey combination or the bigger ones like a plugin for your IDE that re-formats your code. Developers love saving brain power. And if we can save a couple of kilojoules by having a sentence or two in the readme, rather than having discussions in a lengthily thread like this, then well...hey...we have done our part for the next dev that comes along right? |
@nashysolutions I would suggest reading the README again. I think you've missed something here as I'm also not sure what issue you are having here. Out of the box, assertSnapshot will generate images for you when you first run the test. These files will be written to a directory alongside your tests. You need to commit these to your repository - not just so CI can run the tests but also so the rest of your team can run the tests. You didn't need to dig in to the code to find this out. It's right there in the README. You don't need to use the verifySnapshot function at all. |
"I think the readme should have one or two sentences that highlights this particular API and maybe some simple guidance on where to stash the images." I can't explain it in terms simpler than that. |
Taken from the README
No special configuration is needed. The reference snapshots will appear as uncommitted files when you run a git status command.
Here it explains how the snapshot library works. It seems obvious that you’d need to include these references in source control otherwise how else would you expect these tests to run on any other machine? What particular API are you referring to? Is there a specific reason you want to store them somewhere other than the default location? What’s your use case here? |
It may seem obvious about what should happen. But the README does not explain what does happen. This is typical cognitive bias and I would invite you to be careful with words like The README does not explain that the images are stored within the bounds of the project directory. And that running these tests will result in a change to source control. That's the reason I wanted to know if there was API's to control the location of the default directory, for generated images. |
I completely agree that this is not documented properly. 2 years from when this issue is opened there's literally zero mention of CI workflow and best practices in the readme. |
What do you recommend for using this with continuous integration? If the images need to be stored and then subsequently re-run so a comparison can be made, then how would you typically configure your CI setup to keep these images around? I appreciate that there are many CI tools out there and I'm not suggesting specifics. Just some general guidance in the README would be great. Thanks.
The text was updated successfully, but these errors were encountered: