UrbanOS-Public / smart_city_test

Library providing testing functions and data structure generation for the data platform
https://hexdocs.pm/smart_city_test/readme.html
Apache License 2.0
1 stars 1 forks source link

'Eventually without an assert' passes even when it shouldn't. #33

Closed ManApart closed 4 years ago

ManApart commented 5 years ago

Eventually without an assert passes even when it shouldn't. This means tests can give false positives.

AC

TN:

defmodule EventuallyTest do
  use ExUnit.Case
  use Placebo

  import SmartCity.TestHelper

  describe "patiently" do
    # Correctly fails
    test "without assert" do
      Patiently.wait_for!(fn -> true == false end, dwell: 20, max_tries: 10)
    end

    # Correctly fails
    test "with assert" do
      Patiently.wait_for!(fn -> assert true == false end, dwell: 20, max_tries: 10)
    end
  end

  describe "eventually" do
    # Passes when it should not pass
    test "without assert" do
      eventually(fn -> true == false end, 20, 10)
    end

    # Correctly fails
    test "with assert" do
      eventually(fn -> assert true == false end, 20, 10)
    end
  end
end
LtChae commented 5 years ago

Tech note: eventually itself could be fixed to address this as well. Basically, it can check that if it made it into the failure case of its code, it could just raise an error (or warn) that block was falsey but had no assertion. - Ben

bbrewer-forge commented 4 years ago

This was fixed while moving discovery_streams into the umbrella as several tests were written in e2e test that required other changes to eventually (mainly that MatchError were raising out)