Testing ObservableObject

What is the best way to test an ObservableObject?


As a demo, I am trying to make a test, which has a function that takes an enum describing the position on a game board and updates the state of the object.


Is there any way to instantiate the object for testing purposes without the UI (using a Unit Testing Bundle) so that I can test this function without the UI?

Answered by DTS Engineer in 405879022

For those following along at home, Matt G asked the same question over on Swift Forums.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Accepted Answer

For those following along at home, Matt G asked the same question over on Swift Forums.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Testing ObservableObject
 
 
Q