You can put XCTAssert
almost anywhere, which including for/while loop.
I think you need to check the for loop is actually doing what you expected. You can add NSLog
inside the loop to log the value of i
and other variables.
Frage
I'm learning about unit testing and XCode's XCTAssert statements.
I have a situation where I want to test a bunch of things in a sequence, in a dynamic way according to how the environment is set up.
I'm trying to do something like:
for (i = 1, etc...) {
[thisObject doSomethingWith: i];
thatVariable+=i;
XCTAssert ([someComparison basedOn:i], @"Fail text customized to %i", i);
};
...it doesn't work. The test just passes without even seeming to evaluate the XCTAssert statement.
Is this possible?
Lösung
You can put XCTAssert
almost anywhere, which including for/while loop.
I think you need to check the for loop is actually doing what you expected. You can add NSLog
inside the loop to log the value of i
and other variables.