Skip to content
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

Added support for Xcode 9 attachments. #86

Merged
merged 1 commit into from
Jun 25, 2019
Merged

Conversation

reidmain
Copy link

There are four separate PRs (#83, #71, #84, #19) that have attempted to add this feature. Rather than pick a single PR and ask the contributor to update it to sync all of the functionality we decided we would do it ourselves to get this feature out as soon as possible. Thank you @mdiep, @niilohlin, @danieltmbr and @delebedev for your hard work and again I apologize for how long it has taken us to address this.

Across the four PRs there were three unique pieces of functionality that had to be added:

  1. Create an XCTActivity so the attachments can be grouped together for easy inspection.
  2. Attach the reference, failed and diffed images when a test fails.
  3. Attach the recorded image when the tests are run in record mode.

Below are some screenshots to show what Xcode looks like for these scenarios:

Failed Tests
failed
Record Mode
recorded

@CLAassistant
Copy link

CLAassistant commented Jun 20, 2019

CLA assistant check
All committers have signed the CLA.

@rudro rudro requested review from rudro and benpious June 20, 2019 22:30
@rudro rudro assigned reidmain and unassigned rudro, benpious and reidmain Jun 20, 2019
@@ -181,6 +182,23 @@ - (BOOL)saveFailedReferenceImage:(UIImage *)referenceImage
identifier:(NSString *)identifier
error:(NSError **)errorPtr
{
UIImage *diffImage = [referenceImage fb_diffWithImage:testImage];

[XCTContext runActivityNamed:identifier ?: NSStringFromSelector(selector) block:^(id<XCTActivity> _Nonnull activity) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the user should be able to turn this off or on. If you're running a truly massive amount of snapshot tests, you may not want to do this, as it might make Xcode unusable.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm that's a good point. I could easily inflate some of the tests we have locally to fail a couple hundred times if we want but perhaps using the Uber codebase would be a better litmus test?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK so I added a loop around a single test that was failing which ran 15000 times and caused 30000 failures which resulted in 90000 attachments.

I will admit that Xcode really chugged when the tests finished. It beach balled and was non-responsive for like 5-10 minutes while it processed all of the attachments. Navigating to test files as well as the test pane in the report navigator does take a bit of time to load but nothing that I would consider blocking.

If I change the loop to run 5000 times, causing 10000 failures and 30000 attachments there is nearly no issues at all.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created an issue to track adding the ability to turn this feature off #89

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants