diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs index 4b4d6c88807..0f0b2cbe21f 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs @@ -48,7 +48,7 @@ public void AssertHasDevices (bool fail = true) public void DeviceSetup () { SetAdbLogcatBufferSize (64); - RunAdbCommand ("logcat -c"); + ClearAdbLogcat (); CreateGuestUser (GuestUserName); } @@ -69,6 +69,9 @@ public void CheckDevice () TestContext.Out.WriteLine ($"{nameof(CheckDevice)} is restarting the emulator."); RestartDevice (Path.Combine (Root, "Emulator.csproj")); } + + // We want to start with a clean logcat buffer for each test + ClearAdbLogcat (); } [TearDown] @@ -82,6 +85,9 @@ protected override void CleanupTest () string remote = "/data/local/tmp/screenshot.png"; string localUi = Path.Combine (outputDir, "ui.xml"); RunAdbCommand ($"shell screencap {remote}"); + + // Give the app a chance to finish logging + WaitFor (1000); var output = RunAdbCommand ($"logcat -d"); File.WriteAllText (deviceLog, output); RunAdbCommand ($"pull {remote} \"{local}\"");