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

* fix devices test; print on test failure

* mock out a call to Doctor
This commit is contained in:
Devon Carew
2016-09-26 21:28:16 -07:00
committed by GitHub
parent f7d501024c
commit 7238d93e13
3 changed files with 21 additions and 7 deletions

View File

@@ -26,7 +26,7 @@ void testUsingContext(String description, dynamic testMethod(), {
Timeout timeout,
Map<Type, dynamic> overrides: const <Type, dynamic>{}
}) {
test(description, () {
test(description, () async {
AppContext testContext = new AppContext();
overrides.forEach((Type type, dynamic value) {
@@ -65,7 +65,17 @@ void testUsingContext(String description, dynamic testMethod(), {
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);
}
@@ -99,6 +109,10 @@ class MockDeviceManager implements DeviceManager {
}
class MockDoctor extends Doctor {
// True for testing.
@override
bool get canListAnything => true;
// True for testing.
@override
bool get canLaunchAnything => true;