Test with tear down logic isolated to MainActor

I would like to create a test using swift-testing for code isolated to MainActor. The test should have both configuration and cleanup logic also isolated to MainActor.

I found that I can create a class isolated to MainActor with configuration in init and cleanup in deinit. The problem here is that the deinit is not isolated to MainActor. Is there an alternative approach that could be used to achieve what I want?

You're looking for isolated deinit which is being discussed in another thread right now! [Second Review] SE-0371: Isolated synchronous deinit

3 Likes