Git Product home page Git Product logo

Comments (2)

rollbear avatar rollbear commented on July 30, 2024

The REQUIRE_CALL would have to be in a narrower scope than the ALLOW_CALL, which would change your design quite a bit.

I think I'd prefer to let the fixture have a counter for the number of times show_view() has been called. In the situations where it's important that it's called, you can use a normal test framework assertion to make sure that the counter has incremented.

Another technique, if it's important for you that an error is caught by a mock, is to add another constraint on the ALLOW_CALL, that you can programmatically make a not match.

class Test_fixture
{
public:
    void open_file(const fs::path& path) {
        <more expectations>
        ALLOW_CALL(m_mock, show_view())
          .WITH(relaxed);

        m_mock.open_files_clicked();
    }
    bool relaxed = true;
    Mock m_mock;
};

TEST_CASE_METHOD(Test_fixture, "Opening the first file shows the view") {
    relaxed = false;
    REQUIRE_CALL(m_mock, show_view());
    open_file(data_path / "file"); // `ALLOW_CALL` will not match, but `REQUIRE_CALL` above will.
}

from trompeloeil.

Swassie avatar Swassie commented on July 30, 2024

Thanks for the help and your work on the library.

from trompeloeil.

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.