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

Mechanism to reject snapshot. #71

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

babbage
Copy link
Collaborator

@babbage babbage commented Apr 7, 2018

Where a snapshot displays a regression, provides an option to reject a snapshot. This removes the snapshot test files from the test results directory, and removes it from the snapshot results. The original reference file remains.

In order to implement this new function, this pull request implements the same removeTestImages supporter function that is incorporated in the RemoveAccepted pull request. The two pull requests are not however dependent on each other.

@babbage
Copy link
Collaborator Author

babbage commented Apr 7, 2018

One test is failing in this pull request (when tests are run on my local machine), which is due to an error in the test, which is fixed in: #67 Seems to be fine in the Travis CI build which is interesting.

CodeBeat complains of two functions that are too similar. Looking at the code, they are similar for good reason and I can't see a useful way to combine them into a more generic function that would represent an actual code improvement.

@babbage
Copy link
Collaborator Author

babbage commented Apr 7, 2018

The merging of TestResultCell.xib between this pull request and #69 requires careful tweaking as xib files don't merge nicely and there are changes in both. A correctly merged version can be found in this commit: babbage@9829a3c

babbage added 2 commits April 9, 2018 13:06
This function is also identically introduced in the RemoveAccepted pull request.
Where a snapshot displays a regression, provides an option to reject a snapshot. This removes the snapshot test files from the test results directory, and removes it from the snapshot results. The original reference file remains.
Implemented here partly to ease merge with proposed changes in other pull requests.
@babbage
Copy link
Collaborator Author

babbage commented Apr 9, 2018

Rebased onto current master, with change to Accept and Accept All.

@@ -66,4 +67,37 @@ class SnapshotTestResultAcceptor {
throw SnapshotTestResultAcceptorError.canNotPerformFileManagerOperation(testResult: testResult, underlyingError: error)
}
}

func reject(_ testResult: SnapshotTestResult) throws -> SnapshotTestResult {
guard case let SnapshotTestResult.failed(testInformation, referenceImagePath, _, _, build) = testResult, canAccept(testResult) else {
Copy link
Owner

Choose a reason for hiding this comment

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

Should canAccept be here?

@Antondomashnev
Copy link
Owner

@babbage could you please clarify the main use case for the reject button. I'm sure you've added it for reason and I'm curious about it.

@babbage
Copy link
Collaborator Author

babbage commented Apr 18, 2018

Sure, good question. My process was that I have been reviewing a series of test results, and wanted to be able to process them by taking action on each of them, so that when I'm done I'd have an empty list. When a test runs and fails, there's two possible reasons it might fail, and three if the AutoRecord mechanism is added to create test images even when no baseline exists:

  1. The test image represents an improvement in the app, and thus is now the preferred state over the reference image. (ACCEPT)

  2. The test image represents a regression. (REJECT)

  3. There is no reference image. The test image might represent a desirable state (ACCEPT) or might represent a view that is actually revealed to be broken in some way (REJECT).

I selected the word "Reject" because it seemed like the natural partner to "Accept" but taking a different perspective I may have the wrong word here. The intention isn't to reject the test result... actually, quite the opposite. Rather, it's rejecting the test image as a candidate to be a new reference image. Really, what this button is doing is Confirming that the failed test result was correct. It might be that what this suggests is that both "Accept" and "Reject" are the wrong words (ironic given they've only just been integrated) as there is the immediate potential conflict between accepting a test result vs. accepting an image as a new reference image.

What I liked about having this feature was the ability to a) end up with an empty test images folder at the end of processing all the results and b) to have an empty list of test results in FBSnapshotsViewer so I knew I'd reviewed everything. Maybe there is a better process that would give me some of the benefits of feeling like I'd worked through all the results that is different to this?

@babbage
Copy link
Collaborator Author

babbage commented Mar 1, 2019

Would happily continue working on things but for the life of me for months now I've not been able to get FBSnapshotsViewer to respond to failed test snapshots. It just sits inert and doesn't recognise tests have run and have failed. Don't know if there is some incompatibility with something else that has changed in Xcode, or in my setup. Started poking around in parts of FBSnapshotsViewer that I'm not familiar with but I'm not finding it the most straightforward code base to comprehend, and there isn't a lot (any?) documentation on how it is intended to work.

I know this isn't a support channel, so I've delayed posting anything for a long time, but—Is this tool still working for anyone else?

@babbage
Copy link
Collaborator Author

babbage commented Mar 1, 2019

OK, worked out that FBSnapshotsViewer's regex to find test results hadn't been updated to the new .xcresult format. Have written a new regex and it works. Is late. Plan to post as a pull request tomorrow. :)

@babbage babbage self-assigned this Mar 6, 2019
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.

2 participants