File tree Expand file tree Collapse file tree
runner/android_junit_runner
java/androidx/test/internal/runner/junit4/statement Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010
1111* Make perfetto trace sections for tests more identifiable by prefixing with "test:" and using fully qualified class name. (b/204992764)
1212
13+ * Add logs at the start and end of RunBefore and RunAfters sections to help bug understanding. (b/445754263)
14+
1315** Breaking Changes**
1416
1517** API Changes**
Original file line number Diff line number Diff line change 1818
1919package androidx .test .internal .runner .junit4 .statement ;
2020
21+ import android .util .Log ;
2122import java .util .List ;
2223import java .util .concurrent .CopyOnWriteArrayList ;
2324import org .junit .runners .model .FrameworkMethod ;
@@ -32,6 +33,9 @@ public class RunAfters extends UiThreadStatement {
3233
3334 private final List <FrameworkMethod > afters ;
3435
36+ /** Tag for logging. Set to TestRunner to match LogRunListener.TAG for easier debugging. */
37+ private static final String TAG = "TestRunner" ;
38+
3539 /**
3640 * Run all non-overridden {@code @After} methods on this class and superclasses before running
3741 * {@code next}; all After methods are always executed: exceptions thrown by previous steps are
@@ -62,6 +66,7 @@ public void evaluate() throws Throwable {
6266 } catch (Throwable e ) {
6367 errors .add (e );
6468 } finally {
69+ Log .d (TAG , "starting @After execution" );
6570 for (final FrameworkMethod each : afters ) {
6671 if (shouldRunOnUiThread (each )) {
6772 runOnUiThread (
@@ -83,6 +88,8 @@ public void run() {
8388 }
8489 }
8590 }
91+
92+ Log .d (TAG , "finished @After execution" );
8693 }
8794 MultipleFailureException .assertEmpty (errors );
8895 }
Original file line number Diff line number Diff line change 1818
1919package androidx .test .internal .runner .junit4 .statement ;
2020
21+ import android .util .Log ;
2122import java .util .List ;
2223import java .util .concurrent .atomic .AtomicReference ;
2324import org .junit .runners .model .FrameworkMethod ;
@@ -31,6 +32,9 @@ public class RunBefores extends UiThreadStatement {
3132
3233 private final List <FrameworkMethod > befores ;
3334
35+ /** Tag for logging. Set to TestRunner to match LogRunListener.TAG for easier debugging. */
36+ private static final String TAG = "TestRunner" ;
37+
3438 /**
3539 * Run all non-overridden {@code @Before} methods on this class and superclasses before running
3640 * {@code next}; if any throws an Exception, stop execution and pass the exception on.
@@ -52,6 +56,7 @@ public RunBefores(
5256
5357 @ Override
5458 public void evaluate () throws Throwable {
59+ Log .d (TAG , "starting @Before execution" );
5560 final AtomicReference <Throwable > exceptionRef = new AtomicReference <>();
5661 for (final FrameworkMethod before : befores ) {
5762 if (shouldRunOnUiThread (before )) {
@@ -77,6 +82,7 @@ public void run() {
7782 }
7883 }
7984
85+ Log .d (TAG , "finished @Before execution" );
8086 next .evaluate ();
8187 }
8288}
You can’t perform that action at this time.
0 commit comments