I have a test suite that uses Slick access to access DB. Some tests in this package have access to the database, and some do not. My package has
implicit val db = DB.getDB
which effectively initializes DataBaseDefat the start of the package. This value is then used as the implicit parameter value for some methods. It also has afterAll()one that closes dbat the end of the package:
override def afterAll():Unit={
db.close()
super.afterAll()
}
Now, if I changed to:
implicit lazy val db = DB.getDB
what exactly will happen?
If I run only those tests that do not use the database, the connection will not be initialized, but afterAll()it will still try to close the connection, and I have a problem in this case, right? I tried to start, but no error occurred, and there were no exceptions ...
My knowledge of the residuals is not enough to help me understand this in combination with the lazy.
source
share