-
Notifications
You must be signed in to change notification settings - Fork 44
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
[WorkflowTesting] Use CustomDump to better visualize failure messages #214
base: main
Are you sure you want to change the base?
Conversation
94d9058
to
202355f
Compare
@@ -19,6 +19,7 @@ Pod::Spec.new do |s| | |||
s.source_files = 'WorkflowTesting/Sources/**/*.swift' | |||
|
|||
s.dependency 'Workflow', "#{s.version}" | |||
s.dependency 'CustomDump', '~> 0.6.1' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my guess is this is not going to work as a change to the public repo because this has been hosted internally as a pod, but AFAIK does not exist in the public CocoaPods spec repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is correct. Podspecs may not specify "repos" on where the pod comes from and if the podspec is published into the cocoapods trunk (read its open source like Workflow is) then all of its dependencies must be public too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I came across this and it seems public https://github.com/Golface/CocoaPods-Composable-Architecture.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dnkoutso what do you recommend the next step to unblock it would be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DJBen this is a pain...we'd have to ask for someone to publish this in the open source repo or we cannot depend on it. An alternative is to duplicate all of it inside Workflow which is meh. Trying to think of alternatives..........
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I publish it to the trunk, will it solve the issue? Because SQ internally is using a fork, will that cause a version conflict?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you do it would solve this issue here I believe yes.
For SQ if it uses an internal fork it would have to ensure the version requirements specified here match and if they do then I think it will take the fork
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to untangle the public dependency and here's what I find:
CustomDump
depends onXCTestDynamicOverlay
, but it needs > 0.4. Unfortunately, an old 0.1.1 is occupied by another person github.com/Arafo ([email protected]).
Is it okay that I alias the pods with PFC
(pointfreeco), so they become PFCXCTestDynamicOverlay
and PFCCustomDump
, and so I can upload our versions to the public trunk?
I anticipate that may cause source file conflict if in our test, we have both files from CustomDump
and PFCCustomDump
. Another alternative is to cherry-pick and prefix all the files necessary from CustomDump
to this repo. I wonder what you all think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gilgtm I managed to contact Rafa and persuade him to delete the XCTestDynamicOverlay
repo so I can push a new version. I managed to push CustomDump 0.11.0
to cocoapods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contributing this! I share your expectation that just about everyone will prefer this output.
I think we could avoid introducing a new third-party dependency to workflow-swift by either:
- adding a parameter to
tester
orassert
, that accepts a function to use in place ofXCTAssertEqual
- writing an extension within Register that adds a new set of
assert
methods
But both of these would require updating each existing tester
/assert
call site in Register that wants the new behavior, which we don't want to do if this is strictly an improvement. So I think making the change in WorkflowTesting itself is justified.
Can you put up a WIP PR in ios-register that points at this branch of workflow-swift, to verify with CI that none of our tests are somehow depending on specific behaviors of XCTAssertEqual
?
I agree. however I am experencing difficulty of setting up the dependency. I think the follow up steps are blocked until it is resolved |
What is it?
Better visualize the error message by using
CustomDump
inWorkflowTesting
.CustomDump
fromWorkflowTesting
, which is a lightweight opinion-less library that improves printing of any objects by leveragingMirror
s.WorkflowTesting
, replaces all theXCTAssertEquals
intoXCTAssertNoDifference
, which is the go-to method to compare the diff the objects.Why the change?
It has been a constant pain to reveal the differences of two very large structs when
XCTAssertEquals
fails, especially when the difference is minor. Some people resort to https://www.diffchecker.com/, or even subscribe to it to alleviate the issue. The manual copy and paste process is still a sink of engineering time.Introducing the diffing visualization helps developers pinpoint the assertion failure in both local test sor CI pipelines, and speed up development in a long run.
Before:
After:
Impact of the added dependency
The added dependency is added into
WorkflowTesting
, which is meant for the tests modules to depend on. It does not contain any semantic-altering change in workflows.If the consumer module already depends on
CustomDump
, it may cause a version conflict. Fortunately, I synced the dependency toCustomDump
with Square's internal dependent version to avoid this issue.Checklist