0

Many of my tests are dependent on the database. I use the following to check the connection before running the test case:

assume(database.isAvailable, "Database is down")

When I add it to each test case, the correct !!! CANCELED !!! with the correct message is displayed in the output.

When I add it to the beforeEach method:

override def beforeEach() = {
  assume(database.isAvailable, "Database is down")
}

all I can see is just Exception encountered when attempting to run a suite with class name and *** ABORTED *** (on the line with the assume call).

Do I really need to add this assumption to each testcase?

mirelon
  • 4,896
  • 6
  • 40
  • 70
  • Not really an answer, but wouldn't you be better off by mocking the db rather than having it really there? – Diego Martinoia Mar 17 '15 at 10:16
  • Yeah, I have two types of tests: those with database mock and the second type (integration tests) which I want to do this way – mirelon Mar 17 '15 at 11:58

1 Answers1

1

Apparently this is something intended. See

http://www.scalatest.org/user_guide/sharing_fixtures

Mix in a before-and-after trait when you want an aborted suite, not a failed test, if the fixture code fails.

On that same page there are other alternatives. Possibly worths a look withFixture

Gonfva
  • 1,428
  • 16
  • 28