Skip to content

Commit 39a31d9

Browse files
Created a 'known failures' test directory. Updated some docs.
1 parent f884911 commit 39a31d9

File tree

4 files changed

+40
-36
lines changed

4 files changed

+40
-36
lines changed

doc/website/source/golden-scenes/failures.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,25 @@
22
title: Failures
33
navOrder: 40
44
---
5-
`flutter_test_goldens` improves the review experience for failing golden tests.
5+
Building on the concept of [Golden Scenes](/golden-scenes/what-is-it), `flutter_test_goldens` introduces
6+
the concept of "Failure Scenes". A Failure Scene is just like a Golden Scene, except instead of painting
7+
a collection of goldens, it paints a collection of golden mismatch images.
68

7-
Golden failures typically generate four files: the golden image, the new screenshot, an isolated
8-
diff, and a masked diff. These images are useful, but viewing them across four files is tedious.
9+
In Flutter, golden failures typically generate four files:
10+
* The golden image
11+
* The new screenshot
12+
* An isolated diff
13+
* A masked diff.
914

10-
Instead of generating four separate image files upon failure, `flutter_test_goldens` paints
11-
all four of those failure images as a single image, making it easy to view side-by-side.
15+
These images are useful, but viewing them across four files is tedious. Not only do you have to
16+
open and view 4 files to understand 1 failure, but the number of failure files quickly gets out of
17+
control. Imagine goldens that cover 5 different configurations of a widget. Now, imagine that all
18+
5 of those golden tests fail. Flutter would generate 5x4 = 20 failure files. This is intractable
19+
within a production project.
20+
21+
The `golden_toolkit` package improved this issue by placing many different goldens in a single scene.
22+
As a result, those 5 failures would generate a single failure file. But this approach still had its
23+
issues - namely.
1224

1325
Moreover, if a Golden Scene contains more than one golden image, all failure images for all
1426
goldens in the scene, are painted to the same image. This provides the most holistic view

doc/website/source/golden-scenes/gallery.md

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,19 @@ and/or widget configurations.
77

88
```dart
99
await Gallery(
10-
tester,
11-
sceneName: "button_extended_fab_gallery",
12-
layout: SceneLayout.row,
13-
itemDecorator: (context, child) {
14-
return FlutterWidgetScaffold(
15-
child: child,
16-
);
17-
},
10+
"Extended FAB",
11+
fileName: "button_extended_fab_gallery",
12+
layout: ColumnSceneLayout(),
1813
)
1914
.itemFromWidget(
20-
id: "1",
2115
description: "Icon + Text",
2216
widget: FloatingActionButton.extended(
2317
icon: Icon(Icons.edit),
2418
label: Text("Hello"),
25-
onPressed: () {},
19+
onPressed: () {},
2620
),
2721
)
2822
.itemFromWidget(
29-
id: "2",
3023
description: "Icon",
3124
widget: FloatingActionButton.extended(
3225
icon: Icon(Icons.edit),
@@ -35,12 +28,11 @@ await Gallery(
3528
),
3629
)
3730
.itemFromWidget(
38-
id: "3",
3931
description: "Text",
4032
widget: FloatingActionButton.extended(
41-
label: Text("Hello"),
42-
onPressed: () {},
33+
label: Text("Hello"),
34+
onPressed: () {},
4335
),
4436
)
45-
.renderOrCompareGolden();
37+
.run(tester);
4638
```
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
---
2-
title: Filmstrip
2+
title: Timeline
33
navOrder: 30
44
---
5-
A filmstrip is a Golden Scene, which displays a widget at different points in
5+
A timeline is a Golden Scene, which displays a widget at different points in
66
time, and possibly across various user interactions.
77

88
```dart
9-
await FilmStrip(
10-
tester,
11-
goldenName: "button_elevated_interactions",
12-
layout: SceneLayout.row,
9+
await Timeline(
10+
"Elevated Button Interactions",
11+
fileName: "button_elevated_interactions",
12+
layout: RowSceneLayout(),
1313
)
14-
.setupWithPump(() {
15-
return FlutterWidgetScaffold(
14+
.setupWithWidget(
15+
FlutterWidgetScaffold(
1616
goldenKey: goldenKey,
1717
child: ElevatedButton(
1818
onPressed: () {},
1919
child: Text("Hello"),
2020
),
21-
);
22-
})
23-
.takePhoto("idle")
21+
),
22+
)
23+
.takePhoto("Idle")
2424
// Screenshot the hovered state.
2525
.hoverOver(find.byType(ElevatedButton))
26-
.takePhoto("hover")
26+
.takePhoto("Hover")
2727
// Screenshot the pressed state.
2828
.pressHover()
29-
.takePhoto("pressed")
29+
.takePhoto("Pressed")
3030
// Render or compare the scene.
31-
.renderOrCompareGolden();
31+
.run(tester);
3232
```

doc/website/source/golden-scenes/what-is-it.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ A Golden Scene with independent golden images, such as different configurations
1818
widget, is called a [Gallery](/golden-scenes/gallery).
1919

2020
A Golden Scene with golden images that take place over time, such as the idle, hovered, and
21-
pressed state of a button, is called a [Film Strip](/golden-scenes/filmstrip).
21+
pressed state of a button, is called a [Timeline](/golden-scenes/timeline).
2222

2323
## What makes Golden Scenes different?
2424
Fans of golden tests are no doubt familiar with `golden_toolkit`, a package by eBay Motors,
@@ -50,4 +50,4 @@ What if you want to capture the idle state, the hover state, and the pressed sta
5050

5151
`flutter_test_goldens` includes the concept of a `GoldenCamera`, which allows developers to take screenshots
5252
over a period of time. Those screenshots can then be stitched together into a Golden Scene, such as
53-
with a [`FilmStrip`](/golden-scenes/filmstrip).
53+
with a [`Timeline`](/golden-scenes/timeline).

0 commit comments

Comments
 (0)