Skip to content

Commit 1c2946e

Browse files
committed
F!! Verify StoryBoard in try-with-resources
1 parent ae9e9be commit 1c2946e

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

approvaltests-tests/src/test/java/org/approvaltests/StoryBoardTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ void gameOfLife()
2626
@Test
2727
void gameOfLifeWithDescription()
2828
{
29-
GameOfLife gameOfLife = new GameOfLife((x, y) -> y == 2 && 1 <= x && x <= 3);
30-
StoryBoard storyboard = new StoryBoard();
31-
storyboard.addDescription("Game of Life");
32-
storyboard.add(gameOfLife);
33-
storyboard.addFrame("Start Game", gameOfLife.advance());
34-
storyboard.addFrame(gameOfLife.advance());
35-
storyboard.addDescriptionWithData("setting alive", gameOfLife.setAliveCell("*"));
36-
storyboard.addDescriptionWithData("setting dead", gameOfLife.setDeadCell("_"));
37-
storyboard.addFrames(2, gameOfLife::advance);
38-
storyboard.addDescriptionWithData("setting dead", gameOfLife.setDeadCell(" "));
39-
storyboard.addFrames(1, gameOfLife::advance);
40-
Approvals.verify(storyboard);
29+
try (VerifiableStoryBoard storyboard = StoryBoardApprovals.verifyStoryboard()) {
30+
GameOfLife gameOfLife = new GameOfLife((x, y) -> y == 2 && 1 <= x && x <= 3);
31+
storyboard.addDescription("Game of Life");
32+
storyboard.add(gameOfLife);
33+
storyboard.addFrame("Start Game", gameOfLife.advance());
34+
storyboard.addFrame(gameOfLife.advance());
35+
storyboard.addDescriptionWithData("setting alive", gameOfLife.setAliveCell("*"));
36+
storyboard.addDescriptionWithData("setting dead", gameOfLife.setDeadCell("_"));
37+
storyboard.addFrames(2, gameOfLife::advance);
38+
storyboard.addDescriptionWithData("setting dead", gameOfLife.setDeadCell(" "));
39+
storyboard.addFrames(1, gameOfLife::advance);
40+
}
4141
}
4242
@Test
4343
// @UseReporter(QuietReporter.class)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package org.approvaltests;
2+
3+
public class StoryBoardApprovals
4+
{
5+
public static VerifiableStoryBoard verifyStoryboard()
6+
{
7+
return new VerifiableStoryBoard();
8+
}
9+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package org.approvaltests;
2+
3+
public class VerifiableStoryBoard extends StoryBoard implements AutoCloseable
4+
{
5+
@Override
6+
public void close()
7+
{
8+
Approvals.verify(this);
9+
}
10+
}

0 commit comments

Comments
 (0)