Hi everyone in this post we will learn basics of TestNG annotations. In our previous tutorial we have seen introduction and setup of TextNG. Now lets learn what is TestNG annotations and how to use TestNG annotations to define proper test suit execution flow.
TestNG Annotation
Lets understand the simple example given below which will help you understand how annotations helps to define the flow.In TestNG annotations @Test is the smallest annotation here. @Method will be executed first, before and after the execution of @Test. The same way @Class will be executed first, before and after the execution of @Method and so on.
Video Tutorial -
Do try this out and post your feedback and questions in the comment section below.
TestNG Annotation
Lets understand the simple example given below which will help you understand how annotations helps to define the flow.In TestNG annotations @Test is the smallest annotation here. @Method will be executed first, before and after the execution of @Test. The same way @Class will be executed first, before and after the execution of @Method and so on.
Video Tutorial -
Do try this out and post your feedback and questions in the comment section below.
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterMethod; import org.testng.annotations.AfterSuite; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeSuite; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; public class Sequencing {
@BeforeSuite public void beforeSuite() { System.out.println("This will execute before the Test Suite"); }
@BeforeClass public void beforeClass() { System.out.println("This will execute before the Class"); }
@BeforeTest public void beforeTest() { System.out.println("This will execute before the Test"); }
@BeforeMethod public void beforeMethod() { System.out.println("This will execute before every Method"); } @Test public void testCase1() { System.out.println("This is the Test Case 1"); } @Test public void testCase2() { System.out.println("This is the Test Case 2"); } @AfterMethod public void afterMethod() { System.out.println("This will execute after every Method"); } @AfterClass public void afterClass() { System.out.println("This will execute after the Class"); } @AfterTest public void afterTest() { System.out.println("This will execute after the Test"); } @AfterSuite public void afterSuite() { System.out.println("This will execute after the Test Suite"); } }
Article is very informative nice to read it
ReplyDeleteThanks a lot :-)
DeleteI am glad that I saw this post. It is informative blog for us and we need this type of blog thanks for share this blog, Keep posting such instructional blogs and I am looking forward for your future posts. Python Projects for Students Data analytics is the study of dissecting crude data so as to make decisions about that data. Data analytics advances and procedures are generally utilized in business ventures to empower associations to settle on progressively Python Training in Chennai educated business choices. In the present worldwide commercial center, it isn't sufficient to assemble data and do the math; you should realize how to apply that data to genuine situations such that will affect conduct. In the program you will initially gain proficiency with the specialized skills, including R and Python dialects most usually utilized in data analytics programming and usage; Python Training in Chennai at that point center around the commonsense application, in view of genuine business issues in a scope of industry segments, for example, wellbeing, promoting and account. Project Center in Chennai
Delete