VeryGoodOpenSource / very_good_cli

A Very Good Command-Line Interface for Dart created by Very Good Ventures 🦄

Home Page:http://cli.vgv.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Test fails with very_good test but not in flutter test

nerder opened this issue · comments

Description
I'm experimenting with very_good_cli mainly to speed up my tests. Simply running very_good test on my project most of my tests are breaking, while they are not when running them using flutter test.

An example of an error is:

Bad state: Cannot call when within a stub response

on a simple test like this:

    group("on UpdateCapacity event", () {
      var newCapacity = 420;

      setUp(() {
        when(mockLessonRepository.updateLessonCapacity(
                fakeGymId, testLesson.date, testLesson.id, newCapacity))
            .thenAnswer((realInvocation) => Future.value(null));
      });

      tearDown(() {
        verify(mockLessonRepository.updateLessonCapacity(
            fakeGymId, testLesson.date, testLesson.id, newCapacity));
      });

      blocTest(
        "should call repository with newCapacity",
        build: () => EditLessonBloc(
          gymId: fakeGymId,
          lessonId: testLesson.id,
          lessonDate: testLesson.date,
          lessonRepository: mockLessonRepository,
          userRepository: mockUserRepository,
          imageRepository: mockImageRepository,
          storageRepository: mockStorageRepository,
        ),
        act: (bloc) => bloc.add(
          EditLessonEvent.updateCapacity(
            newCapacity: newCapacity,
          ),
        ),
        expect: () => [],
      );
    });

Why is that?

Hello there, thanks for opening an issue.

Even though I can see some irregularities from your code inspection, I will need more details of the caught error (stack trace, etc.) and a replicable code sample.

Hello @nerder, there are some cases that can cause tests to break on very_good test that would pass on flutter test:

  • Dependency in between tests
  • Expects on teardown
  • Vars defined outside of the usual test scaffolding (setup/setupAll).

Try to run flutter test with random test ordering to see if it breaks.

Hey @nerder since this seems to be silent for a while, i am closing this for now. If anything comes up, dont hesitate on telling.

Hello, got the same issue that @nerder . Is there a solution on it ?

Hi @baptistemchl thank you for following up. There might be many reasons on why tests fail with very_good test and not with flutter test. Feel free to open a new issue and provide some guidance on how we can reproduce the behaviour 🙌

Hey @alestiago , finally find a the solution to my problem. In fact i had 2 goldens generated files with the same name. :)