Skip to content

Commit

Permalink
added acceptance and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anetep committed Jun 10, 2022
1 parent 33e1c5e commit 2cb76bd
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 27 deletions.
16 changes: 0 additions & 16 deletions unimeals/README.md

This file was deleted.

1 change: 0 additions & 1 deletion unimeals/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
26 changes: 16 additions & 10 deletions unimeals/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}

}
Empty file.
13 changes: 13 additions & 0 deletions unimeals/test_driver/features/goToRestaurantButton.feature
Original file line number Diff line number Diff line change
@@ -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 <restaurantPage> page

Examples:
| restaurantPage |
| "Grill" |
| "Cafetaria - Restaurante Feup" |
| "Restaurante do INEGI" |
10 changes: 10 additions & 0 deletions unimeals/test_driver/steps/goToRestaurantButtonStep.dart
Original file line number Diff line number Diff line change
@@ -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<String,FlutterWorld>("I expect to be in the <string> restaurant page", (key, context) async {
final locator = find.byValueKey(key);
await FlutterDriverUtils.tap(context.world.driver, locator);
});
}
10 changes: 10 additions & 0 deletions unimeals/test_driver/steps/tapButton.dart
Original file line number Diff line number Diff line change
@@ -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<String,FlutterWorld>("I tap the <string> back button", (key, context) async {
final locator = find.byValueKey(key);
await FlutterDriverUtils.tap(context.world.driver, locator);
});
}

0 comments on commit 2cb76bd

Please sign in to comment.