Testing ObservableObject

Is there a way to write a unit test for an ObservableObject class?

In what way? You can observe @Published properties and test them pretty easily, but since the objectWillChange publisher's default implementation only works with SwiftUI, if you want to test the observability of the whole object you'll need to provide your own, which is pretty easy, though I'm not sure if it's worth it.

1 Like

I figured out what I was doing wrong. I was not using the @testable tag for my imports.