Technologies - TestNG Framework - Annotation attributes

 

Annotation Attributes - methods of annotations

Attributes are keywords that modify the annotation's function.

 

alwaysrun:
                If set to true, this test method will always be run even if it depends on a method that failed.

dataProvider
  The name of the data provider for this test method.

dataProviderClass
          The class where to look for the data provider. If not specified, the data provider will be looked on the class of the current test method or one of its base classes. If this attribute is specified, the data provider method needs to be static on the specified class.

dependsOnGroups
  The list of groups this method depends on.

dependsOnMethods
           The list of methods this method depends -Non dependent @test will be executed in Ascii order followed by dependent tests - when a single test is

dependent on multiple tests then attribute syntax will be as follows (dependsOnMethod={"methods1","method2"})


description
  The description for this method.

enabled
  Whether methods on this class/method are enabled.

expectedExceptions
         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.

groups
  The list of groups this class/method belongs to.

priority
         The priority for this test method. Lower priorities will be scheduled first [-ve values also considered]- default priority is '0' - if priority is same, execution is based on Ascii order of the Tests 

timeOut
         The maximum number of milliseconds this test should take.

invocationCount 

          Executes same Test case multiple times sequentially with same set of data - default invocation count is '1'.

 

threadPoolSize 
          Used along with invocationCount - helps to execute same Test case @Test in parallel instead of sequential execution.

 

invocationTimeOut

          Used along with invocationCount - Validates Timeout of entire invocation count - throws "threadTimeOut" exception if exceeds TimeOut provided - Timeout mentioned in milliSeconds.

 

timeOut

         Validates the timeout of @Test annotation - considers each iteration of Test case for the specified timeout - throws "threadTimeOut" exception if exceeds TimeOut provided 

 

successPercentage

         Inorder to check the stability of the test based on the condition - successPercentage

 


Simple Example:

@Test(description = "This a new test", timeOut = 20000, priority = -200, dependsOnMethods = "test1", groups ="tutorial")
   public void test2(){
        ...

   }

 

Comments

Popular posts from this blog

QA's approach 2 Java - Understanding Static context

QA's approach 2 Java - Collections Framework & Generics Introduction

Technologies - Log4J - Create Log4j Configuration File - Where ? How ? What ?