0

I want to write a unit test function, which aims at testing uploading happens when the app is running in the background. It is generally like this:

func checkBackgroundUploading() {
   set the UIState to be background
   write a record and upload it to database in this UIState
}

I know how to do the second step, but how to set the UIState to be background?

Sunil Sharma
  • 2,653
  • 1
  • 25
  • 36
Miranda
  • 129
  • 3
  • 12

1 Answers1

1

I have had success in testing sounds in the background by using this solution, that I found on SO. The gist of it is to send the app to the background by programmatically pressing the home button. Hope it helps.

    XCUIDevice().pressButton(XCUIDeviceButton.Home)
Community
  • 1
  • 1
FromTheStix
  • 429
  • 5
  • 10