When you attempt running unit test using VSTS Agent Plan, you may see an error message:

iOSSimulator: Timed out waiting 120 seconds for simulator to boot, current state is 1.

Start the iOS simulator differently

You should start the iOS Simulator by using the following command:

>xcrun simctl boot "iPhone 7"

To run xcodebuild with test configuration:

>xcodebuild test -project MyApp.xcodeproj -scheme MyApp –destination "platform=iOS Simulator,name=iPhone 7"

Make sure to terminate the simulator at the end to keep the build state clean:

>xcrun simctl shutdown "iPhone 7"