From acf96ad482aeff857290c9886b719629b2e561ce Mon Sep 17 00:00:00 2001 From: fiatcode Date: Tue, 10 Feb 2026 11:36:11 +0700 Subject: [PATCH] REFACTOR: tests clean up --- test/bowling_game_test.dart | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/test/bowling_game_test.dart b/test/bowling_game_test.dart index 71e9aa1..870b869 100644 --- a/test/bowling_game_test.dart +++ b/test/bowling_game_test.dart @@ -3,23 +3,25 @@ import 'package:test/test.dart'; void main() { group('Bowling Game', () { - test('gutter game - all zeros', () { - final game = BowlingGame(); + late BowlingGame game; - for (int i = 0; i < 20; i++) { - game.roll(0); + setUp(() { + game = BowlingGame(); + }); + + void rollMany(int times, int pins) { + for (int i = 0; i < times; i++) { + game.roll(pins); } + } + test('gutter game - all zeros', () { + rollMany(20, 0); expect(game.score(), 0); }); test('all ones - score is 20', () { - final game = BowlingGame(); - - for (int i = 0; i < 20; i++) { - game.roll(1); - } - + rollMany(20, 1); expect(game.score(), 20); }); });