Fakultas Ilmu Komputer UI

Commit c8380a3b authored by Fakhira Devina's avatar Fakhira Devina
Browse files

[CHORE] Debug flutter test in pipeline

parent a69a1a2a
Pipeline #37289 failed with stages
in 1 minute and 39 seconds
<<<<<<< HEAD
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":[]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.5\\\\","dependencies":[]}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-1.0.6\\\\","dependencies":[]},{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.5\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-0.0.4\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"google_maps_flutter","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]}],"date_created":"2020-03-25 16:01:43.498294","version":"1.15.17"}
=======
<<<<<<< HEAD
{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"google_maps_flutter","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]}]}
=======
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":[]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-1.0.6\\\\","dependencies":[]},{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"google_maps_flutter","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","dependencies":[]}],"date_created":"2020-03-25 16:26:56.154526","version":"1.15.17"}
>>>>>>> staging
>>>>>>> PBI-2-pencarian_lokasi
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":[]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.5\\\\","dependencies":[]}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-1.0.6\\\\","dependencies":[]},{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.5\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-0.0.4\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"google_maps_flutter","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]}],"date_created":"2020-03-25 16:48:42.556715","version":"1.15.17"}
\ No newline at end of file
......@@ -22,8 +22,8 @@ Lint:
Test:
stage: test
script:
- flutter test --machine > tests.output
- flutter test --coverage
- flutter test --machine > tests.output
- lcov --summary coverage/lcov.info
- genhtml coverage/lcov.info --output=coverage
artifacts:
......
......@@ -29,7 +29,7 @@ class CookiesInterface {
await getApplicationDocumentsDirectory().then((Directory directory) {
dir = directory;
});
File cookieFile = new File("${dir.path}/usercookies.json");
File cookieFile = File("${dir.path}/usercookies.json");
cookieFile.createSync();
setCookie = responseHeaders["set-cookie"];
......@@ -47,7 +47,7 @@ class CookiesInterface {
return cookieFile;
} on Exception catch (e) {
print(e.toString());
throw e;
rethrow;
}
}
......@@ -60,7 +60,7 @@ class CookiesInterface {
await getApplicationDocumentsDirectory().then((Directory directory) {
dir = directory;
});
File cookieFile = new File(dir.path + "/searchhistory.json");
File cookieFile = File(dir.path + "/searchhistory.json");
cookieFile.createSync();
await checkCookieFileAvailability(fileName: "searchhistory").then((available) async {
if (available) {
......@@ -77,12 +77,12 @@ class CookiesInterface {
} else {
currentSearchHistory = [];
}
cookieFile.writeAsString(json.encode(currentSearchHistory));
await cookieFile.writeAsString(json.encode(currentSearchHistory));
});
return cookieFile;
} on Exception catch (e) {
print(e.toString());
throw e;
rethrow;
}
}
......
......@@ -46,7 +46,7 @@ class DashboardState extends State<Dashboard> {
}
void enableLocationService() async {
location.changeSettings(accuracy: LocationAccuracy.HIGH);
await location.changeSettings(accuracy: LocationAccuracy.HIGH);
_serviceEnabled = await location.serviceEnabled();
if (!_serviceEnabled) {
_serviceEnabled = await location.requestService();
......
......@@ -81,7 +81,7 @@ class PencarianState extends State<Pencarian> {
case Status.COMPLETED:
recentSearch = snapshot.data.data;
Widget displayWidget;
if (recentSearch.listLokasi.length == 0) {
if (recentSearch.listLokasi.isEmpty) {
displayWidget = Center(
child: Text("Anda belum pernah melakukan pencarian"));
} else {
......
......@@ -3,31 +3,38 @@ import 'package:mockito/mockito.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:ppl_disabilitas/network/network_interface.dart';
import 'package:ppl_disabilitas/page/dashboard/dashboard.dart';
import 'package:http/http.dart' as http;
import 'package:pedantic/pedantic.dart';
class MockNavigatorObserver extends Mock implements NavigatorObserver {}
class MockNetwork extends Mock implements NetworkInterface {}
class MockHttp extends Mock implements http.Client {}
void main() {
group('Dashboard navigation tests', () {
NavigatorObserver mockObserver;
NetworkInterface mockNetwork;
MockHttp mockHttp;
setUp(() {
mockObserver = MockNavigatorObserver();
mockNetwork = MockNetwork();
when(mockNetwork.get(isLogin: false, url: anyNamed('url'))).thenAnswer((_) async {
mockHttp = MockHttp();
when(mockHttp.get('http://wwww.google.com'))
.thenAnswer((_) async => http.Response('{"title": "Test"}', 200));
when(mockNetwork.get(isLogin: false, url: anyNamed('url')))
.thenAnswer((_) async {
await Future.delayed(Duration(milliseconds: 50));
return Future<dynamic>.value(
[
{
"nama": "Coolidge",
"latitude": -23.7169139,
"longitude": -46.8498038,
"alamat": "74809 Hooker Drive",
"telepon": "+55 956 836 5799"
}
]
);
return Future<dynamic>.value([
{
"nama": "Coolidge",
"latitude": -23.7169139,
"longitude": -46.8498038,
"alamat": "74809 Hooker Drive",
"telepon": "+55 956 836 5799"
}
]);
});
});
......@@ -53,27 +60,28 @@ void main() {
testWidgets(
'when tapping text form field, should navigate to pencarian page',
(WidgetTester tester) async {
final textFieldKeyPencarian = Key("Text Field Mau Kemana");
await _buildDashboardPage(tester);
await _navigateToPencarianPage(tester);
verify(mockObserver.didPush(any, any));
expect(find.byKey(textFieldKeyPencarian), findsOneWidget);
});
(WidgetTester tester) async {
final textFieldKeyPencarian = Key("Text Field Mau Kemana");
await _buildDashboardPage(tester);
await _navigateToPencarianPage(tester);
verify(mockObserver.didPush(any, any));
expect(find.byKey(textFieldKeyPencarian), findsOneWidget);
});
testWidgets('tapping the back button should navigate back to the dashboard',
(WidgetTester tester) async {
final backIconKey = Key("Back Icon Key");
await _buildDashboardPage(tester);
await _navigateToPencarianPage(tester);
await tester.pump();
final Route pushedRoute =
verify(mockObserver.didPush(captureAny, any)).captured.single;
String popResult;
pushedRoute.popped.then((result) => popResult = result);
await tester.tap(find.byKey(backIconKey));
await tester.pumpAndSettle();
expect(popResult, 'Take me back');
});
(WidgetTester tester) async {
final backIconKey = Key("Back Icon Key");
await _buildDashboardPage(tester);
await _navigateToPencarianPage(tester);
await tester.pump();
final Route pushedRoute =
verify(mockObserver.didPush(captureAny, any)).captured.single;
String popResult;
unawaited(pushedRoute.popped.then((result) => popResult = result));
await tester.tap(find.byKey(backIconKey));
await tester.pumpAndSettle();
expect(popResult, 'Take me back');
});
});
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment