Apologies, this is not an answer to your actual question. But in general, I'd suggest to make them runnable in parallel. SwiftNIO supports passing port 0 meaning "find a random free port" which is what NIO and most other stuff does in its test suites. That means you can easily run one fresh server per test case; the test cases would just interrogate the server about "what port should I use for this test?".
Thank you Johannes. This is a good point. The challenge here is we need to spwan a mock server and then tell the Lambda Runtime Client where to connect to.
Having a fixed port number helped. Otherwise, I need to figure out a way to report the actual port number to the client.
So far, we never had a conflict, even when executing the test in parallel. But i want to play it future-proof and safe.