Commit 7238d93e authored by Devon Carew's avatar Devon Carew Committed by GitHub

fix devices test; print on test failure (#6039)

* fix devices test; print on test failure

* mock out a call to Doctor
parent f7d50102
...@@ -24,7 +24,7 @@ import 'create_test.dart' as create_test; ...@@ -24,7 +24,7 @@ import 'create_test.dart' as create_test;
import 'daemon_test.dart' as daemon_test; import 'daemon_test.dart' as daemon_test;
import 'devfs_test.dart' as devfs_test; import 'devfs_test.dart' as devfs_test;
import 'device_test.dart' as device_test; import 'device_test.dart' as device_test;
// import 'devices_test.dart' as devices_test; import 'devices_test.dart' as devices_test;
import 'drive_test.dart' as drive_test; import 'drive_test.dart' as drive_test;
import 'format_test.dart' as format_test; import 'format_test.dart' as format_test;
import 'install_test.dart' as install_test; import 'install_test.dart' as install_test;
...@@ -58,7 +58,7 @@ void main() { ...@@ -58,7 +58,7 @@ void main() {
daemon_test.main(); daemon_test.main();
devfs_test.main(); devfs_test.main();
device_test.main(); device_test.main();
// devices_test.main(); // https://github.com/flutter/flutter/issues/4480 devices_test.main();
drive_test.main(); drive_test.main();
format_test.main(); format_test.main();
install_test.main(); install_test.main();
......
...@@ -14,16 +14,16 @@ void main() { ...@@ -14,16 +14,16 @@ void main() {
group('devices', () { group('devices', () {
testUsingContext('returns 0 when called', () { testUsingContext('returns 0 when called', () {
DevicesCommand command = new DevicesCommand(); DevicesCommand command = new DevicesCommand();
return createTestCommandRunner(command).run(<String>['list']).then((int code) { return createTestCommandRunner(command).run(<String>['devices']).then((int code) {
expect(code, 0); expect(code, 0);
}); });
}); });
testUsingContext('no error when no connected devices', () { testUsingContext('no error when no connected devices', () {
DevicesCommand command = new DevicesCommand(); DevicesCommand command = new DevicesCommand();
return createTestCommandRunner(command).run(<String>['list']).then((int code) { return createTestCommandRunner(command).run(<String>['devices']).then((int code) {
expect(code, 0); expect(code, 0);
expect(testLogger.statusText, contains('No connected devices')); expect(testLogger.statusText, contains('No devices detected'));
}); });
}, overrides: <Type, dynamic>{ }, overrides: <Type, dynamic>{
AndroidSdk: null, AndroidSdk: null,
......
...@@ -26,7 +26,7 @@ void testUsingContext(String description, dynamic testMethod(), { ...@@ -26,7 +26,7 @@ void testUsingContext(String description, dynamic testMethod(), {
Timeout timeout, Timeout timeout,
Map<Type, dynamic> overrides: const <Type, dynamic>{} Map<Type, dynamic> overrides: const <Type, dynamic>{}
}) { }) {
test(description, () { test(description, () async {
AppContext testContext = new AppContext(); AppContext testContext = new AppContext();
overrides.forEach((Type type, dynamic value) { overrides.forEach((Type type, dynamic value) {
...@@ -65,7 +65,17 @@ void testUsingContext(String description, dynamic testMethod(), { ...@@ -65,7 +65,17 @@ void testUsingContext(String description, dynamic testMethod(), {
testContext[XCode] = new XCode(); testContext[XCode] = new XCode();
} }
return testContext.runInZone(testMethod); try {
return await testContext.runInZone(testMethod);
} catch (error) {
if (testContext[Logger] is BufferLogger) {
BufferLogger bufferLogger = testContext[Logger];
if (bufferLogger.errorText.isNotEmpty)
print(bufferLogger.errorText);
}
throw error;
}
}, timeout: timeout); }, timeout: timeout);
} }
...@@ -99,6 +109,10 @@ class MockDeviceManager implements DeviceManager { ...@@ -99,6 +109,10 @@ class MockDeviceManager implements DeviceManager {
} }
class MockDoctor extends Doctor { class MockDoctor extends Doctor {
// True for testing.
@override
bool get canListAnything => true;
// True for testing. // True for testing.
@override @override
bool get canLaunchAnything => true; bool get canLaunchAnything => true;
......
Markdown is supported
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