How do I fix Init() error when unit testing a method that builds a new instance of a view, that contains a listview

Viewed 80

I have a custom navigation method that builds a new instance of a view. Unit tests for this method fail with the error message

System.InvalidOperationException: You must call Xamarin.Forms.Forms.Init(); prior to using this property.

I know that the listview in the view is causing it as the unit tests succeed when the listview is removed.

I have seen in older posts and blogs that this is because platformServices needs to be set but this cannot be set externally and the solutions point to github repositories or nuget packages that no longer exist or don't go into detail.

Any advice would be appreciated.

0 Answers
Related