@@ -87,7 +87,8 @@ void defineReflectiveTests(Type type) {
8787 {
8888 var isSolo = _hasAnnotationInstance (classMirror, soloTest);
8989 var className = MirrorSystem .getName (classMirror.simpleName);
90- group = _Group (isSolo, _combineNames (_currentSuiteName, className));
90+ group = _Group (isSolo, _combineNames (_currentSuiteName, className),
91+ classMirror.testLocation);
9192 _currentGroups.add (group);
9293 }
9394
@@ -104,7 +105,7 @@ void defineReflectiveTests(Type type) {
104105 // test_
105106 if (memberName.startsWith ('test_' )) {
106107 if (_hasSkippedTestAnnotation (memberMirror)) {
107- group.addSkippedTest (memberName);
108+ group.addSkippedTest (memberName, memberMirror.testLocation );
108109 } else {
109110 group.addTest (isSolo, memberName, memberMirror, () {
110111 if (_hasFailingTestAnnotation (memberMirror) ||
@@ -137,7 +138,7 @@ void defineReflectiveTests(Type type) {
137138 }
138139 // skip_test_
139140 if (memberName.startsWith ('skip_test_' )) {
140- group.addSkippedTest (memberName);
141+ group.addSkippedTest (memberName, memberMirror.testLocation );
141142 }
142143 });
143144
@@ -154,7 +155,9 @@ void _addTestsIfTopLevelSuite() {
154155 for (var test in group.tests) {
155156 if (allTests || test.isSolo) {
156157 test_package.test (test.name, test.function,
157- timeout: test.timeout, skip: test.isSkipped);
158+ timeout: test.timeout,
159+ skip: test.isSkipped,
160+ location: test.location);
158161 }
159162 }
160163 }
@@ -304,23 +307,25 @@ class _AssertFailingTest {
304307class _Group {
305308 final bool isSolo;
306309 final String name;
310+ final test_package.TestLocation ? location;
307311 final List <_Test > tests = < _Test > [];
308312
309- _Group (this .isSolo, this .name);
313+ _Group (this .isSolo, this .name, this .location );
310314
311315 bool get hasSoloTest => tests.any ((test) => test.isSolo);
312316
313- void addSkippedTest (String name) {
317+ void addSkippedTest (String name, test_package. TestLocation ? location ) {
314318 var fullName = _combineNames (this .name, name);
315- tests.add (_Test .skipped (isSolo, fullName));
319+ tests.add (_Test .skipped (isSolo, fullName, location ));
316320 }
317321
318322 void addTest (bool isSolo, String name, MethodMirror memberMirror,
319323 _TestFunction function) {
320324 var fullName = _combineNames (this .name, name);
321325 var timeout =
322326 _getAnnotationInstance (memberMirror, TestTimeout ) as TestTimeout ? ;
323- tests.add (_Test (isSolo, fullName, function, timeout? ._timeout));
327+ tests.add (_Test (isSolo, fullName, function, timeout? ._timeout,
328+ memberMirror.testLocation));
324329 }
325330}
326331
@@ -341,14 +346,26 @@ class _Test {
341346 final String name;
342347 final _TestFunction function;
343348 final test_package.Timeout ? timeout;
349+ final test_package.TestLocation ? location;
344350
345351 final bool isSkipped;
346352
347- _Test (this .isSolo, this .name, this .function, this .timeout)
353+ _Test (this .isSolo, this .name, this .function, this .timeout, this .location )
348354 : isSkipped = false ;
349355
350- _Test .skipped (this .isSolo, this .name)
356+ _Test .skipped (this .isSolo, this .name, this .location )
351357 : isSkipped = true ,
352358 function = (() {}),
353359 timeout = null ;
354360}
361+
362+ extension on DeclarationMirror {
363+ test_package.TestLocation ? get testLocation {
364+ if (location case var location? ) {
365+ return test_package.TestLocation (
366+ location.sourceUri, location.line, location.column);
367+ } else {
368+ return null ;
369+ }
370+ }
371+ }
0 commit comments