jeudi 3 décembre 2015

ScalaTest shared behaviour functions fail early

I'm trying to run tests by sharing behaviour in traits. When I run such a test, the test always aborts early when there's a failure, not running the rest of the tests.

Here's my test:

trait TestBehaviour extends ShouldMatchers {
  def failEarly = fail("this fails before the test is run")
  def failEarlyAgain = fail("this also fails before the test is run")
}

class Test extends FlatSpec with TestBehaviour {

  it must behave like failEarly

  it must behave like failEarlyAgain  
}

If I run this in the ScalaTest IDE for Eclipse, no tests are ever shown - the RUN ABORTED text is just shown in the console:

*** RUN ABORTED ***
  An exception or error caused a run to abort: this fails before the test is run

So it looks like the first test is being run early.

What I would expect to see is both the tests are run, and fail (with different reason messages).

Aucun commentaire:

Enregistrer un commentaire