I have written a few testcases with specs2 in play framework using Slick with MySQL database connection. A Database Connection rejected error is thrown for the later testcase, hence results in failure.
the error thrown is
Task slick.backend.DatabaseComponent$DatabaseDef$$anon$2@4877c5d rejected from java.util.concurrent.ThreadPoolExecutor@48e736[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 1] (DatabaseComponent.scala:230)
The code for testcase is written in this format -
class tryTests extends PlaySpecification{
"Application" should {
"test1" in new WithApplication{
/* Some tests
}
"test2" in new WithApplication{
/* Some tests
}
}
}
So the test1 will succeed successfully but test2 will fail with above mentioned error.
The sollutions that I've tried so far are
- using the "sequential" keyword
- using the function override method for "is"
- trying to connect with database in "before" part "with BeforeAfterEach"
Above 3 mentioned methods did not work out. Till now according to my understanding the problem is that testcases are being executed concurrently and each one disconnects the database connection. So the later testcase is not able to access the same.
Any suggestion for this problem !!!
Aucun commentaire:
Enregistrer un commentaire