inUnitTest property
Returns true if we are running in a unit test. We do this by inspecting the stack looking for the test_api package so this method has very limited use and is intended for internal dcli testing.
Implementation
@visibleForTesting
bool get inUnitTest {
Frame? scriptFrame;
for (final frame in Trace.current().frames) {
if (frame.package != null && frame.package == 'test_api') {
if (scriptFrame != null) {
_unitTestPath = truepath(scriptFrame.library);
}
return true;
}
scriptFrame = frame;
}
return false;
// p.extension(Platform.script.toFilePath()) == '.dill' &&
// p.basenameWithoutExtension(Platform.script.toFilePath()) ==
// 'test.dart_1';
}