This is my query. It's inside of the Tests target. And I set the applicationID and clientKey inside of AppDelegate.swift.
I put a breakpoint in AppDelegate.swift, so that is definitely getting hit when I run the test. It also hit the breakpoint I set before line 5 of the code below (customer.saveinbackgroundWithBlock...). But when I put a breakpoint right after that line, it wouldn't hit it, and the test would "succeed." Also, the Parse Dashboard shows that no customer was added.
I tested the same query in the normal app target, and that worked. Just not in test target.
func testCustomersExistCase() {
// Save a test customer
let customer = Customer(firstName: "Jonathan", lastName: "Goldsmith", email: "theMostInterestingManInTheWorld@en.wikipedia.org", streetAddress: "100 Main St", city: "Monterrey", state: "Texas", zipCode: "55555")
customer.shopID = "dosequis"
customer.saveInBackgroundWithBlock({
(success: Bool, error: NSError?) -> Void in
if success {
print("This test should work.")
self.customerSearchViewControllerDataSource.getAllCustomers(self.customeSearchViewController)
// Check if it's in the customers array
for customerResult in self.customeSearchViewController.data! {
if customerResult.objectId == customer.objectId {
XCTAssertTrue(true, "Success! Customer was added.")
// Delete customer if test had succeeded.
customer.deleteInBackgroundWithBlock({
(success: Bool, error: NSError?) -> Void in
if success {
print("Clean-up after test was successful")
} else {
print("Need to delete customer manually")
}
})
} else {
XCTAssertTrue(false, "Query is broken. Customer was not retrieved")
}
}
} else {
print("This test will not work. Customer was not added to Parse")
}
if error != nil {
print("This test isn't working. Parse threw an error.")
}
})
}
}
Aucun commentaire:
Enregistrer un commentaire