isRunningInTest top-level property

bool isRunningInTest

Tells whether the code is running in test.

If you want to add tear-downs, use TestEnvironment.addTearDown.

Example

import 'package:os/os.dart';

void doSomething() {
  if (isRunningInTest) {
    // ...
  } else {
    // ...
  }
}

See also

Implementation

bool get isRunningInTest => TestEnvironment.current != null;