How to test that dart:developer.log is called?

22 views Asked by At

I have a method

import 'dart:developer' as developer;

void myMethod(bool parameter) {
  if (parameter) {
    developer.log('foo');
  } else {
    developer.log('bar');
  }
}

I want to write a test that verifies developer.log is correctly called depending on the parameters.

test('It should log foo', () {
  myMethod(true);
  // Verify `developer.log` was called with `'foo'`.
});

test('It should log bar', () {
  myMethod(false);
  // Verify `developer.log` was called with `'bar'`.
});

How can I verify that developer.log was called with a specific parameter?

0

There are 0 answers