KARASZI István
KARASZI István

Reputation: 31467

Is there a way to count the number of assertions in TestNG?

Actually the title includes the question.

I would like to know how many assertions have been evaluated in the tests.

Upvotes: 1

Views: 1022

Answers (2)

Cedric Beust
Cedric Beust

Reputation: 15608

The short answer is no.

What you can do is use your own asserts and maintain a counter there.

Upvotes: 0

Wim Deblauwe
Wim Deblauwe

Reputation: 26858

You could use aspectj for this. If you define a pointcut that matches with assert calls, you can keep a counter in an aspect and report that counter after the tests have run.

If you make the pointcut finegrained enough, you could count assertTrue() different from assertEquals(), etc.. if you would want that.

Upvotes: 1

Related Questions