felangel / mocktail

A mock library for Dart inspired by mockito
https://pub.dev/packages/mocktail
MIT License
588 stars 80 forks source link

captureAny list order differs in release mode #229

Closed brianneal-wf closed 4 months ago

brianneal-wf commented 4 months ago

Describe the bug

We have a large set of unit tests that we converted from mockito to mocktail. One thing we noticed was the verification result list order was different when the test was run in release mode. The same test under mockito would pass in both DDC and release modes.

To Reproduce

We have some code like this:

          final captured = verify(() => myMock.myMethod(
                position1,
                position2,
                named1: 'foo',
                named2: 'bar',
                a: captureAny(named: 'a'),
                b: captureAny(named: 'b'),
                c: captureAny(named: 'c'),
              )).captured;

Expected behavior

Under mockito captured is, in both DDC and release modes, in the order a, b, c.

Under mocktail captured is in the above order in DDC mode but the order is different when the tests are compiled in release mode (from memory I think it was c, a, b).

Just curious if this is intentional and we can't count on the order or if this is a bug?

felangel commented 4 months ago

Hi @brianneal-wf 👋 Thanks for opening an issue!

I'll try to see if I can reproduce this locally but in the meantime if you can provide a reproduction sample and the steps you're taking the run the test, I'd greatly appreciate it, thanks!

brianneal-wf commented 4 months ago

@felangel Sorry I should have tried that before opening the issue. I created a sample app locally with a test that mirrors our real test but the issue does not reproduce. We are thinking it might be related to optimization levels in use, but really have no idea. You can probably close this issue for now.

BTW, thank you so much for mocktail we are very excited to use it and to avoid the generation times of mockito.

felangel commented 4 months ago

@felangel Sorry I should have tried that before opening the issue. I created a sample app locally with a test that mirrors our real test but the issue does not reproduce. We are thinking it might be related to optimization levels in use, but really have no idea. You can probably close this issue for now.

BTW, thank you so much for mocktail we are very excited to use it and to avoid the generation times of mockito.

No worries at all! Really appreciate the kind words and please let me know if you're able to reproduce this and I'm more than happy to take a closer look 👍