From 2cb76bd757480b5ba37d53dbc8e4a034f08da95b Mon Sep 17 00:00:00 2001 From: Anete Date: Fri, 10 Jun 2022 19:52:45 +0100 Subject: [PATCH] added acceptance and unit tests --- unimeals/README.md | 16 ------------ unimeals/pubspec.yaml | 1 - unimeals/test/widget_test.dart | 26 ++++++++++++------- .../test_driver/features/backButton.feature | 0 .../features/goToRestaurantButton.feature | 13 ++++++++++ .../steps/goToRestaurantButtonStep.dart | 10 +++++++ unimeals/test_driver/steps/tapButton.dart | 10 +++++++ 7 files changed, 49 insertions(+), 27 deletions(-) delete mode 100644 unimeals/README.md create mode 100644 unimeals/test_driver/features/backButton.feature create mode 100644 unimeals/test_driver/features/goToRestaurantButton.feature create mode 100644 unimeals/test_driver/steps/goToRestaurantButtonStep.dart create mode 100644 unimeals/test_driver/steps/tapButton.dart diff --git a/unimeals/README.md b/unimeals/README.md deleted file mode 100644 index 57d8db0..0000000 --- a/unimeals/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# unimeals - -A new Flutter project. - -## Getting Started - -This project is a starting point for a Flutter application. - -A few resources to get you started if this is your first Flutter project: - -- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) -- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) - -For help getting started with Flutter, view our -[online documentation](https://flutter.dev/docs), which offers tutorials, -samples, guidance on mobile development, and a full API reference. diff --git a/unimeals/pubspec.yaml b/unimeals/pubspec.yaml index b18d68e..8d04809 100644 --- a/unimeals/pubspec.yaml +++ b/unimeals/pubspec.yaml @@ -68,7 +68,6 @@ flutter: # To add assets to your application, add an assets section, like this: assets: - assets/images/ - - assets/json/sigarra.json # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware. diff --git a/unimeals/test/widget_test.dart b/unimeals/test/widget_test.dart index c6539a7..18bd155 100644 --- a/unimeals/test/widget_test.dart +++ b/unimeals/test/widget_test.dart @@ -7,22 +7,28 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:unimeals/view/pages/mainPage.dart'; + + + void main() { - testWidgets('Counter increments smoke test', (WidgetTester tester) async { + + testWidgets('Navigation from main page to restaurant page', (WidgetTester tester) async { // Build our app and trigger a frame. - await tester.pumpWidget(const MaterialApp()); + await tester.pumpWidget(MainPage()); - // Verify that our counter starts at 0. - expect(find.text('0'), findsOneWidget); - expect(find.text('1'), findsNothing); + // Verify that it finds the text "Ver localização" inside restaurant page + expect(find.text('Grill'), findsOneWidget); + expect(find.text('Ver localização'), findsNothing); - // Tap the '+' icon and trigger a frame. - await tester.tap(find.byIcon(Icons.add)); + // Tap the '->' icon and trigger a frame. + await tester.tap(find.byIcon(Icons.arrow_forward_rounded)); await tester.pump(); // Verify that our counter has incremented. - expect(find.text('0'), findsNothing); - expect(find.text('1'), findsOneWidget); + expect(find.text('Grill'), findsNothing); + expect(find.text('Ver localização'), findsOneWidget); }); -} + +} \ No newline at end of file diff --git a/unimeals/test_driver/features/backButton.feature b/unimeals/test_driver/features/backButton.feature new file mode 100644 index 0000000..e69de29 diff --git a/unimeals/test_driver/features/goToRestaurantButton.feature b/unimeals/test_driver/features/goToRestaurantButton.feature new file mode 100644 index 0000000..3ebf402 --- /dev/null +++ b/unimeals/test_driver/features/goToRestaurantButton.feature @@ -0,0 +1,13 @@ +Feature: Forward Button to restaurants pages + The button should go to the page of the restaurant clicked + + Scenario Outline: Forward Button redirects you to the page of the restaurant + Given I expect to be in the main page + When I tap the button button forward + Then I expect to be redirected to the page + + Examples: + | restaurantPage | + | "Grill" | + | "Cafetaria - Restaurante Feup" | + | "Restaurante do INEGI" | \ No newline at end of file diff --git a/unimeals/test_driver/steps/goToRestaurantButtonStep.dart b/unimeals/test_driver/steps/goToRestaurantButtonStep.dart new file mode 100644 index 0000000..1bf3bd8 --- /dev/null +++ b/unimeals/test_driver/steps/goToRestaurantButtonStep.dart @@ -0,0 +1,10 @@ +import 'package:flutter_driver/flutter_driver.dart'; +import 'package:flutter_gherkin/flutter_gherkin.dart'; +import 'package:gherkin/gherkin.dart'; + +StepDefinitionGeneric GoFoward() { + return when1("I expect to be in the restaurant page", (key, context) async { + final locator = find.byValueKey(key); + await FlutterDriverUtils.tap(context.world.driver, locator); + }); +} \ No newline at end of file diff --git a/unimeals/test_driver/steps/tapButton.dart b/unimeals/test_driver/steps/tapButton.dart new file mode 100644 index 0000000..48b1a15 --- /dev/null +++ b/unimeals/test_driver/steps/tapButton.dart @@ -0,0 +1,10 @@ +import 'package:flutter_driver/flutter_driver.dart'; +import 'package:flutter_gherkin/flutter_gherkin.dart'; +import 'package:gherkin/gherkin.dart'; + +StepDefinitionGeneric TapButton() { + return when1("I tap the back button", (key, context) async { + final locator = find.byValueKey(key); + await FlutterDriverUtils.tap(context.world.driver, locator); + }); +} \ No newline at end of file