Reputation: 5712
I'm using TestNG. I'm having a test case which is running for both admin users as well as standard users. For admin users expected behavior is no exceptions and task get success while for standard users expected is a exception. In this kind of scenario what is the best approach?
expectedExceptions
annotation with some conditionI can use try catch inside the method and check for the condition. But I think it is not a good practice.
Upvotes: 1
Views: 129
Reputation: 311998
The expectedExceptions
doesn't have any additional properties (like conditions).
Just write two separate tests, one for admins and one for regular users.
Upvotes: 2