Skip to main content

TestNG Annotations

TestNG support different type of the Annotations. TestNG uses these annotations to execute the Test Cases, Here we are showing the different type of the Annotations.

  • @BeforeSuite will run before  the all test method in this suite will run. It run single time only. 
  • @AfterSuite will run after all test method will run in this suite. It also run single time only.
  • @BeforeTest will be run before any test method belonging to the class inside the <test> tag is run
  • @AfterTest will be run after the all test method belonging to the class inside the <test> tag have run
  • @BeforeGroup: The list of Group that this configuration method will run before. @BeforeGroup will guarantee to run shortly before the First test method that belong to any of these groups is invoked.
  •  @AfterGroup: The list of Group that this configuration method will run after. @AfterGroup will guarantee to run shortly after the First test method that belong to any of these groups is invoked.
  • @BeforeClass will be run before the first test method in the current class is invoked.
  • @AfterClass will be run after all the test method in the current class has been invoked.
  • @BeforeMethod will be run before each test method.
  • @AfterMethod will be run after each test method.
  • @Test: Mark a class or a method as a part of the test 
  • @Parameters: This Annotations describe how to pass the parameters to a @Test Method. 
  • @Listeners: Define listeners on a test class. 
  • @Factory: Mark a method as Factory that returns object that will be used by TestNG as Test Classes. That method must return Object[].
  • @DataProvider: Mark a method as supplying data for a test method. An Annotation method must return object[][] where each object can assigned the parameter list of the test method. The @Test method that want top receive data from this DataProvider needs to use a DataProvider name equals to the name of this annotations.

Comments

Popular posts from this blog

What is API?

In general way, API (Application Programming Interface) is the intermediate software which is useful for two applications to communicate. API is the tool which is used for interaction of two applications. If developer developing any software which have multiple blocks (Modules) than developer use APIs to put them together.

Structural Testing

Structural Testing is the type of testing in which user should have the knowledge of the code because in this testing user need to check the structure of the system. Structural Testing is White Box Testing.