Not if you can avoid it
By which I mean, depending on what you're using to do your unit tests, you might not be able to realistically avoid it. In that case, do as needs must
If you run your assert in a loop, you effectively have one test which is testing an arbitrary number of things. That's going to get confusing.
What you want is multiple tests which test one thing each.
Some test frameworks (like NUnit for C#) allow you to define a test that takes parameters and then define the values to repeat the test with.
e.g.
[TestCase(1, 1, 2)]
[TestCase(2, 3, 5)]
[TestCase(0, -1, -1)]
public void MyTest(int a, int b, int expected) {
Assert.AreEqual(expected, a + b);
}
If your framework supports that, it's wonderfully easy to do.
Alternatively, if you're using a script language (e.g. javascript), you might be able to define your tests in a loop, rather than the asserts.
e.g.
describe('My tests', function() {
var testCases = [
{a: 1, b: 1, expected: 2},
{a: 2, b: 3, expected: 5},
{a: 0, b: -1, expected: -1}
]
testCases.forEach(function(t) {
it(`Adds ${t.a} and ${t.b} correctly`, function() {
assert.equal(t.expected, t.a + t.b);
});
});
})
This defines many tests, testing a single thing. Not one test testing many things. Which subsequently makes it much easier to see which one fails when it does.