I am new in Testing in Objective-C but I have some experience in .NET with MSTest.
What is the best way to compare two objects in objective C using XCTAssert?
Example code is below:
- (void)testNumericValue_SaveAndLoad_ShouldSaveAndThenLoadIdenticalObject
{
[_numericValue_1 saveToDatabaseWithKey:VALID_KEY_1];
NumericValue *tmpNumericValue = [[NumericValue alloc] loadFromDatabaseWithKey:VALID_KEY_1];
XCTAssertEqualObjects(tmpNumericValue, _numericValue_1);
}
- (void)testLoop_SaveAndLoad_ShouldSaveAndThenLoadIdenticalObject
{
[_loop_1 saveToDatabase];
Loop *tmpLoop = [[Loop alloc] loadFromDatabase];
XCTAssertEqualObjects(tmpLoop, _loop_1);
}
I have many tests like this. I am sure that save
and load
functions work in a proper way. Some of this tests are passing, some are failing. What is the reason?
I want this objects to have same properties values. I have to compare all of this properties one by one? Is there any "cleaner" way?
Thank you for your time