Giter Club home page Giter Club logo

Comments (5)

Amir-P avatar Amir-P commented on May 18, 2024 1

Ok I found the problem within a minute after creating the issue. setUp is calling before every test not group. So stubbing should be done inside a test.

from mocktail.

rich-j avatar rich-j commented on May 18, 2024 1

@felangel The example provided by @Amir-P above shows the issue. This sequence

...
group('description', () {
    MockOtherTestClass otherTestClass = MockOtherTestClass();
    when(() => otherTestClass.test(any())).thenReturn('expected');
    test('test', () {
...

will continue to tell you to add a setup that calls registerFallbackValue even after you add the recommended code.

The only way to make it work is to move the when into the test

...
group('description', () {
    MockOtherTestClass otherTestClass = MockOtherTestClass();
    test('test', () {
        when(() => otherTestClass.test(any())).thenReturn('expected');
...

from mocktail.

rich-j avatar rich-j commented on May 18, 2024

@felangel, we encountered this too (and took longer than a minute to figure it out). It would be useful if there were a different message printed for when clauses using any in the group that explicitly mentions that any has to be in a test.

BTW, thanks for this package. The new Mockito generator didn't understand many things (covariant parameters, parameters on toString, even Iterable). Except for this issue (which we encountered on our first conversion of any) the migration to Mocktail was straightforward.

from mocktail.

felangel avatar felangel commented on May 18, 2024

Hi @rich-j 👋
Thanks for the positive feedback! I really appreciate it 🙏

Are you able to provide a simple reproduction sample of the problem you were facing? I'm happy to improve the error messaging, thanks! 👍

from mocktail.

felangel avatar felangel commented on May 18, 2024

Got it, thanks for clarifying 👍

I've created #41 to track this improvement 😄

from mocktail.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.