top of page
sejalben3

@Test Annotation and its attributes



In any automation script, @Test annotation is the important part, where we write code/business logic. If something needs to be automated, that particular code needs to be inserted into the test method. The test method then executes @Test by passing attributes. Here are some attributes that are used to pass in the test methods.

  • dependsOnGroups: In this attribute, we can get a group of the list to the particular method it depends on.

Example: @Test (groups = { "Organization" ,"Employee" })

  • alwaysRun: This attribute can be used whenever we get a situation to run a method continuously, even if the parameters of the process fail.

Example: @Test(alwaysRun = true)

  • dataProviderClass: dataProviderClass is class used to provide the data to the dataProvider, so let’s give the class name “Computer.”

data Provider: It is used for providing any data to the parameterization.

Example: @Test (dataProvider = "Computer")

  • dependsOnMethods: TestNg executes Test methods in alphabetic orders in that case if second test method wants to be dependent on first test method then we can use dependsenOnMethods attribute. In this case If first test method fails, second test method which is dependent on first method will not run.

  • Example: @Test (dependsOnMethods = { "start", "init" })


6 views0 comments

Recent Posts

See All

Comments


bottom of page