Innopolis University DevOps Playground
Skip to content
Snippets Groups Projects
Commit f143fe70 authored by Azizullo Sadriddinzoda's avatar Azizullo Sadriddinzoda
Browse files

unit test

parent 9e402bb9
Branches
No related tags found
No related merge requests found
Pipeline #2317 failed
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility in the flutter_test package. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:proj3/main.dart';
import 'package:proj3/pages/achievements_page.dart';
import 'package:proj3/pages/categories_page.dart';
import 'package:proj3/pages/difficulty_page.dart';
import 'package:proj3/pages/story_mode_page.dart';
import 'package:proj3/widgets/achievement_box.dart';
void main() {
testWidgets('Main Page Test', (tester) async {
......@@ -29,47 +16,4 @@ void main() {
});
testWidgets("Select Difficulty Page Test", (tester) async {
// Go to Difficulty page and check if Next button and difficulty buttons are there
await tester.pumpWidget(Difficulty());
expect(find.text("Easy"), findsOneWidget);
expect(find.text("Random"), findsOneWidget);
expect(find.text("Next"), findsOneWidget);
});
testWidgets("Select Category Page Test", (tester) async {
// Go to Categories page and check if categories are there
await tester.pumpWidget(MaterialApp(home: CategoriesPage()));
expect(find.byKey(Key("categories")), findsOneWidget);
});
testWidgets('Story Mode Page Test', (tester) async {
// Go to StoryMode page
await tester.pumpWidget(StoryMode());
// Verify if there is a Start button, Add category button and Increment/Decrement buttons
expect(find.text("Start"), findsOneWidget);
expect(find.byIcon(Icons.add), findsWidgets);
expect(find.byIcon(Icons.remove), findsWidgets);
// Verify if the initial number of words is 1
expect(find.text("1"), findsOneWidget);
expect(find.text("2"), findsNothing);
// Press plus button, and change the frame
await tester.tap(find.byKey(Key("increment")));
await tester.pump();
// Verify if the number incremented
expect(find.text("1"), findsNothing);
expect(find.text("2"), findsOneWidget);
});
testWidgets("Achievements Page Test", (tester) async {
// Go Achievements page and verify if you can see the achievements
await tester.pumpWidget(Achievements());
expect(find.byType(AchievementBox), findsWidgets);
});
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment