Hi everyone, in this post we will see how to priorities Test cases in TestNG and how to sequence it as per our requirement. If you create a test class and add multiple test cases and run it then each time test case execution sequence is randomly selected .
With TestNG annotations @Test and parameter "priority" we can define sequence and priority for executing test cases. Let us consider the below example and if you run the test class given below multiple times you can see that each time execution sequence/flow is different hence to define a fixed execution flow we user TestNG annotation priority.
Given below is the example for using priority annotations. When you run the below test class then each time execution flow is constant and starts with test case having 0 priority.
If you come across a situation where there is requirement to skip some tests then in this case you can do it using @Test annotations and enabled parameter.
With TestNG annotations @Test and parameter "priority" we can define sequence and priority for executing test cases. Let us consider the below example and if you run the test class given below multiple times you can see that each time execution sequence/flow is different hence to define a fixed execution flow we user TestNG annotation priority.
Video Tutorial -
package test; import org.testng.annotations.Test; public class TesNGSequencing { @Test public void One() { System.out.println("Test Case number One"); } @Test public void Two() { System.out.println("Test Case number Two"); } @Test public void Three() { System.out.println("Test Case number Three"); } @Test public void Four() { System.out.println("Test Case number Four"); } }
Given below is the example for using priority annotations. When you run the below test class then each time execution flow is constant and starts with test case having 0 priority.
package test; import org.testng.annotations.Test; public class TesNGSequencing { @Test(priority=0) public void One() { System.out.println("Test Case number One"); } @Test(priority=1) public void Two() { System.out.println("Test Case number Two"); } @Test(priority=2) public void Three() { System.out.println("Test Case number Three"); } @Test(priority=3) public void Four() { System.out.println("Test Case number Four"); } }
Skipping a Test -
If you come across a situation where there is requirement to skip some tests then in this case you can do it using @Test annotations and enabled parameter.
package test; import org.testng.annotations.Test; public class TesNGSequencing { @Test(priority=0, enabled=false) public void One() { System.out.println("Test Case number One"); } @Test(priority=1) public void Two() { System.out.println("Test Case number Two"); } @Test(priority=2) public void Three() { System.out.println("Test Case number Three"); } @Test(priority=3) public void Four() { System.out.println("Test Case number Four"); } }
AWS Training in Bangalore - Live Online & Classroom
ReplyDeletemyTectra Amazon Web Services (AWS) certification training helps you to gain real time hands on experience on AWS. myTectra offers AWS training in Bangalore using classroom and AWS Online Training globally. AWS Training at myTectra delivered by the experienced professional who has atleast 4 years of relavent AWS experince and overall 8-15 years of IT experience. myTectra Offers AWS Training since 2013 and retained the positions of Top AWS Training Company in Bangalore and India.
IOT Training in Bangalore - Live Online & Classroom
IOT Training course observes iot as the platform for networking of different devices on the internet and their inter related communication. Reading data through the sensors and processing it with applications sitting in the cloud and thereafter passing the processed data to generate different kind of output is the motive of the complete curricula. Students are made to understand the type of input devices and communications among the devices in a wireless media.
Very interesting information and this is very useful in my future. Please update them.
ReplyDeleteExcel Training in Chennai
Excel classes in Chennai
Tableau Training in Chennai
Oracle Training in Chennai
Linux Training in Chennai
Spark Training in Chennai
Embedded System Course Chennai
Oracle DBA Training in Chennai
Excel Training in Vadapalani
Excel Training in Thiruvanmiyur
Great Article. Thank you for sharing! Really an awesome post for every one.
ReplyDeleteIEEE Final Year projects Project Centers in Chennai are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation. For experts, it's an alternate ball game through and through. Smaller than expected IEEE Final Year project centers ground for all fragments of CSE & IT engineers hoping to assemble. Final Year Project Domains for IT It gives you tips and rules that is progressively critical to consider while choosing any final year project point.
Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Spring Framework Corporate TRaining the authors explore the idea of using Java in Big Data platforms.
Specifically, Spring Framework provides various tasks are geared around preparing data for further analysis and visualization. Spring Training in Chennai
Great Blog!!! Thanks for sharing this wonderful post with us.
ReplyDeletePython Training in Chennai
Python course in Chennai
Python Classes in Chennai
Python Training Institute in Chennai
Pyhton training in Adyar
Python Training in Tnagar
Big data training in chennai
Hadoop training in chennai
Digital Marketing Course in Chennai
Selenium Training in Chennai
Great post!! Thanks for sharing...
ReplyDeleteSoftware Testing Course in Bangalore
Nice post, I like to read this blog. It is very interesting to read.
ReplyDeletetop 10 uses of python
jobs for ccna certified
scope of php in future
future scope of machine learning
data science interview questions and answers