Giter VIP home page Giter VIP logo

ex_assert_eventually's People

Contributors

kelostrada avatar rslota avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

kelostrada

ex_assert_eventually's Issues

Unexpected behaviour

Hello,

I'm curious if it's intentional behaviour that condition check inside eventually triggered at least twice even if the first call of it yields a successful result?

To demonstrate this I tweaked one of your tests:

    test "when match is successful from the first try" do
      {:ok, mock} =
        start_supervised(
          {MockOperation, [success_return: :ok, failure_return: :error, fail_times: 0]}
        )

      returne_value = assert_eventually :ok = MockOperation.do_something(mock), :ok

      assert returne_value == :ok

      stats = MockOperation.get_stats(mock)
      # by default there should be one call each 20ms
      assert stats.call_counter ==  1
    end

This test will fail as call_counter is gonna be equal 2 and not 1 even though the condition was met after the first call of eventually "block".

I looked through the tests and my guess is that you might have thought of scenarios when the state eventually settles and the assertion yields the same results from one point onward. But imagine the scenario when you getting messages from the queue and you are not sure whether the message is ready to be consumed or delay is required. assert_eventually looks like the right tool for this job, right? Wrong! If it's just one message and it's ready to be consumed by the time of the first call, it's gonna fetch it with the first call and will fail ugly later on even though the condition of assertion was met. This behaviour is unexpected and it took me some time to figure why my test fails as the matcher basically breaks the expectation of how it should behave.

Would it be possible to change that so assert_eventually would be useful in the scenario I described as well?

[bug] Warnings on assignments while using eventually macro

Consider this test:

   test "hello world" do
    eventually assert variable = Module.hello()
    assert :world == variable
  end

If you compile this on Elixir 1.11+ you get this warning:

Compiling 1 file (.ex)
Generated eventually_variable app
warning: variable "variable" is unused (if the variable is not meant to be used, prefix it with an underscore)
  test/eventually_variable_test.exs:8: EventuallyVariableTest."test get meaningful value by using normal assert"/1

..

Finished in 0.05 seconds
1 doctest, 1 test, 0 failures

Randomized with seed 920761

Obviously the variable is used later in the assert, but the compiler doesn't see that.

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.