Unit Test Concrete Method of Abstract Class in Dart

287 Views Asked by At

I have an abstract class written in Dart, that not only contains abstract method but also contains concrete methods like below:

 abstract class Person {
  void speak();
  Foot getFoot();

  void walk() {
    getFoot().move();
  }
}

class Foot {
  void move() {
  }
}

Test:

 class MockPerson extends Person {

  @override
  Foot getFoot() {
    return Foot();
  }

  @override
  void speak() {
  }
}


void main() {
  late MockPerson sut;

  setUp(() {
    sut = MockPerson();
  });

  test('test walk', () {
    /// ??
  });
}

I tried to created mock of Person to be able to test against it. But I'm not sure how can I write unit test for walk() method?

0

There are 0 best solutions below