Skip to content

Commit 477a52e

Browse files
Make perfetto trace sections for tests more identifiable by prefixing with "test:" and using fully qualified class name.
PiperOrigin-RevId: 853342216
1 parent 0ca3f40 commit 477a52e

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

runner/android_junit_runner/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
**New Features**
1010

11+
* Make perfetto trace sections for tests more identifiable by prefixing with "test:" and using fully qualified class name. (b/204992764)
12+
1113
**Breaking Changes**
1214

1315
**API Changes**

runner/android_junit_runner/java/androidx/test/internal/runner/listener/TraceRunListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void testStarted(Description description) throws Exception {
3636
String testClassName =
3737
description.getTestClass() != null ? description.getTestClass().getSimpleName() : "None";
3838
String methodName = description.getMethodName() != null ? description.getMethodName() : "None";
39-
Trace.beginSection(sanitizeSpanName(testClassName + "#" + methodName));
39+
Trace.beginSection(sanitizeSpanName("test:" + testClassName + "#" + methodName));
4040
}
4141

4242
@Override

runner/android_junit_runner/javatests/androidx/test/runner/TraceRunListenerTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ public void createsSection_withShortName() throws Exception {
5252
listener.testFinished(description);
5353

5454
assertThat(ShadowTrace.getCurrentSections()).isEmpty();
55-
assertThat(ShadowTrace.getPreviousSections()).containsExactly("ClassUnderTest#theMethodName");
55+
assertThat(ShadowTrace.getPreviousSections())
56+
.containsExactly("test:ClassUnderTest#theMethodName");
5657
}
5758

5859
@Test
@@ -72,7 +73,7 @@ public void createsSection_withLongName() throws Exception {
7273
assertThat(ShadowTrace.getCurrentSections()).isEmpty();
7374
assertThat(ShadowTrace.getPreviousSections())
7475
.containsExactly(
75-
"ClassUnderTest#anExcessivelyLongDescriptionStringWithLengthAboveThe127CharLimitWillBeTrimmedToAvoidThrowingAnExceptionFromBegin");
76+
"test:ClassUnderTest#anExcessivelyLongDescriptionStringWithLengthAboveThe127CharLimitWillBeTrimmedToAvoidThrowingAnExceptionFrom");
7677
}
7778

7879
private static final class ClassUnderTest {}

0 commit comments

Comments
 (0)