Hi,
I'm trying to test a view model that conforms to ObservableObject
with swift testing.
My test looks like
@Test("When a filter is selected the 'save search' button is enabled")
func testWhenAFilterIsSelectedTheSaveButtonIsEnabled() {
let viewModel = GxClassSearchFormViewModel(
filterSelection: .init(),
currentSavedSearch: nil
)
// when
viewModel.filterSelection.clubs.select(hasle)
// then
#expect(viewModel.savedSearchState == .active)
#expect(viewModel.isSavedSearchButtonDisabled)
}
Interestingly, this test crashes on the iOS 16.2 Simulator. I'm using Version 16.2 (16C5032a)
It crashes at the macro level like:
And I don't understand what's wrong really. Maybe a concurrency issue? not sure.
Xcode stops the execution and the debug navigator shows and incredibly long stack trace. I add images from the top and bottom of it as it's too long to add it all
Has anyone experience a similar issue?
It has happened to me in other tests too, sometimes when using #required