Skip to content

Instantly share code, notes, and snippets.

@lando2319
Last active August 13, 2022 15:32
Show Gist options
  • Select an option

  • Save lando2319/81102e774b8c0ef4e838ea1d033c1c6d to your computer and use it in GitHub Desktop.

Select an option

Save lando2319/81102e774b8c0ef4e838ea1d033c1c6d to your computer and use it in GitHub Desktop.
UI Testing on different devices was causing the order to be different, big devices would be "10, 6", small devices would be "6, 10", I wanted it to check for either.
func assertStringEqualsEitherOrder(labelToTest: String, baseLabel:String, checkLabel:String) -> Bool {
if labelToTest == "\(baseLabel), \(checkLabel)" { return true }
if labelToTest == "\(checkLabel), \(baseLabel)" { return true }
return false
}
// example usage
assert(
assertStringEqualsEitherOrder(
labelToTest: app.buttons["place10"].label,
baseLabel: "10",
checkLabel: "6"
)
)
assert(
assertStringEqualsEitherOrder(
labelToTest: app.buttons["place10"].label,
baseLabel: "NINE",
checkLabel: "50, 5" // Odds and Flat
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment