utest icon indicating copy to clipboard operation
utest copied to clipboard

eventually + assertMatch

Open NeQuissimus opened this issue 6 years ago • 3 comments

Using a combination of eventually and assertMatch is currently rather inconvenient. assertMatch returns Unit while eventually expects Boolean.

So the following piece of code does not compile

  eventually {
        assertMatch(y) {
          case Success(x: String) if x == "bla" =>
        }
      }

while this does but only with a manual true as a workaround.

  eventually {
      assertMatch(y) {
        case Success(x: String) if x == "bla" =>
      }
      true
    }

Maybe an eventually that only cares about match errors or a new eventuallyMatch could be added?

NeQuissimus avatar May 02 '18 12:05 NeQuissimus

In my opinion, the following should be plenty enough:

eventually {
  assert(condition)
  true
}

No need for assertThis, assertThat, assertWhatever. No need for eventuallyThis, eventuallyThat, eventuallyWhatever. If you seek the convenience of such this that whatever, you should employ ScalaTest instead, not uTest.

frgomes avatar May 04 '18 22:05 frgomes

@frgomes Thanks for the friendly contribution. My point is that I don't think it should be necessary to add a manual true after the assert. I would have expected my first code snippet to compile.

NeQuissimus avatar May 04 '18 22:05 NeQuissimus

@NeQuissimus :: I certainly understand your point. My point is that uTest should not be polluted with this, that, whatever just because API X has a certain function or syntax construct which happens to not look nice or convenient. You may have a myriad of circumstances where something may not look nice or convenient and, if we extend uTest everytime something does not look nice or convenient, uTest will soon look like ScalaTest.

frgomes avatar May 04 '18 22:05 frgomes