Group Group Group Group Group Group Group Group Group

Shutdown() was not called before Application deinitialized

Following the sample code for the book in writing tests. Now find that tests basically grind to a halt before anything really runs, and always with this message:

**Vapor/Application.swift:154: Fatal error: Application.shutdown() was not called before Application deinitialized.**

The tests were working, and even now, having destroyed and recreated docker containers running the pg database, I can see that the the automigrate process does insert data that is part of the tests. But I can’t get any further than this crash and error.

From what I can tell, the first test runs, and migrates everything, but when it ends, it seems to not clean up – or well, I don’t really know.

Hi, I usually get this error, when my DB I use for the test runs is not started in Docker. I use different DBs for development, testing and production environments and sometimes I forget to switch.

1 Like

Have a look at Failure when running tests where someone had a similar problem. Wrapping trys in a do/catch is a good start

1 Like