Closed pedromassango closed 1 month ago
@pedromassango could you provide a sample (failing) test? I assume that it's passing locally? If so, what platform are you running locally?
@pedromassango could you provide a sample (failing) test? I assume that it's passing locally? If so, what platform are you running locally?
It is a private project, you can reproduce with a simple golden test using alchemist
@pedromassango could you provide a sample (failing) test? I assume that it's passing locally? If so, what platform are you running locally?
It is a private project, you can reproduce with a simple golden test using alchemist
Could you answer the other questions I had? Thank you!
MacOS
Sorry, I missed this thread
I looked into this today and was not able to reproduce. I have a sample repo here.
The test is here.
A successful CI run was here. In case you're not able to see that, I've attached a screenshot of the run below.
Of note, the CI goldens were produced on CI itself via this workflow. This has proven to be very reliable for us at Betterment to avoid any oddities in the way Flutter UI renders on different platforms, even when text is accounted for via the Ahem
font. As noted in other tickets, sometimes half-pixel render differently depending on the platform; it's recommended to generate your CI goldens on CI.
I'm going to close this as I don't think there's an action item for us, but please do feel free to open again if you have a reproducing sample or any questions. Thank you!
@btrautmann thank you, seems the only way to make the CI test to work.
How to you make sure a new PR won't break a Widget? Will the CI fails if the image differs from the existing one?
How to you make sure a new PR won't break a Widget? Will the CI fails if the image differs from the existing one?
Correct, testing a Widget
for something like a PR is all business as usual, the test will get run on CI (and therefore the test image is generated by CI), comparing the test image against the master image. That's why it makes sense (and is most reliable) to generate master images on CI itself.
That is amazing, I couldn't really find this information anywhere else, so just to make sure I got this right:
The flow is:
Is that the flow I should aim for & you are using internally? I am just trying to get an understanding of this, and than for the insights
@pedromassango yeah you are correct, that's pretty much the workflow. The bit there that isn't done for you out of the box is the generation of goldens via CI. There is a bit of discussion around the matter here, but nothing is currently planned at this time to make this automatic.
At Betterment, our general flow is:
bt/my-new-widget
. This workflow runs flutter test --update-goldens
and commits the changes to that branch.flutter test
.From our standpoint, we don't really even use platform goldens except for local validations.
PS: Much of this is mentioned in the setup guide, worth a read!
That is nice.
Goldens are generated via a manually invoked workflow (kicked off via GHA workflow dispatch GUI, pointed at the feature branch, e.g bt/my-new-widget. This workflow runs flutter test --update-goldens and commits the changes to that branch.
Would be nice to have an automation for this too.
Anyway, thans for sharing, I believe now it is clear in what worflow to have with golden tests
- Goldens are generated via a manually invoked workflow (kicked off via GHA workflow dispatch GUI, pointed at the feature branch, e.g
bt/my-new-widget
. This workflow runsflutter test --update-goldens
and commits the changes to that branch.
Hi @btrautmann I have another question, does that means, for the first time, I should first open a PR with the golden tests & flutter test --generate-goldens
and then run tests without the generate flag?
My current setup is failing because the first images were generated on my laptop (macOs) and during CI the comparison fails
Is there an existing issue for this?
Version
0.7.0
Description
Test fails in CI with the default configuration, it works locally with
flutter run test
Config:
Steps to reproduce
use the setup code above, generate any golden test and make it run on CI with a linux env, see CI failing with:
Expected behavior
test should pass
Screenshots
No response
Additional context and comments
No response