@Test Attributes TimeOut,expectedExceptions,invocationCount Attributes in Testng



TestNG is a testing framework mainly used for unit testing of the Java projects. The Testng has pre-defined annotations and attributes associated with the annotations would help to verify the application accordingly as per the expected result. The following attributes are applied for @Test attribute

  1. timeOut
  2. expectedExceptions
  3. invocationCount

timeOut Attribute:

The maximum number of milliseconds this test should take. If the execution time of the test case takes more than the timeOut value provided, the test case will Fail.

timeOut Attribute Example


timeOut,expectedExceptions Attribute

timeOut,expectedExceptions Attribute


expectedExceptions Attribute:

The list of exceptions that a test method is expected to throw. If no exception or a different than one on this list is thrown, this test will be marked a failure.

expectedExceptions Attribute Example:


invocationCount Attribute:

The number of times this method should be invoked.

invocationCount Attribute Example

Leave a Reply

Your email address will not be published. Required fields are marked *