TestNG - Attributes
TestNG - Attributes ~30 mins

TestNG Attributes

What are Attributes?

Why do we need to use it?

When to use attributes?

TestNg –Helper attributes

Available attributes in TestNG:

Attributes- Priority

Syntax :

  @Test(priority=1)
public void m1() {

}

Attribute-enabled

  @Test(enabled=false)
public void m1(){

}

Attribute- invocationCount

  @Test(invocationCount=3)
public void m1(){

}
  @Test(invocationCount=3,invocationTimeOut=3000)
public void m1(){

}

Attribute -threadPoolSize

  @Test(invocationCount=3,threadPoolSize=2)
public void m1(){

}

*Method will be executed thrice in parallel run with 2 threads

Attribute-dependsOnMethods

  @Test(dependsOnMethods={"method2","method3"})
public void m1(){

}
@Test
public void method2(){

}
@Test
public void method3(){

}
  @Test(dependsOnMethods="packageName.className.methodName")
public void m1(){
}

Attribute -alwaysRun

  @Test(dependsOnMethods="method2" , alwaysRun=true)
public void m1(){

}

@Test
public void method2(){
throw new Exception();
}