how to use testng annotation @BeforeTest? @BeforeTest (TestNG)

@BeforeTest: The annotated method will be run before any test method belonging to the classes inside the <test> tag is run.
@AfterTest: The annotated method will be run after all the test methods belonging to the classes inside the <test> tag have run.

 &lt;!DOCTYPE suite SYSTEM &quot;http://testng.org/testng-1.0.dtd&quot;&gt;

&lt;suite name=&quot;Suite1&quot;&gt;

&lt;test name=&quot;testing Test_Base&quot;&gt;
 &lt;classes&gt;
 &lt;class name=&quot;testWordpress.Test_Base&quot; &gt;&lt;/class&gt;
 &lt;/classes&gt;
&lt;/test&gt;


&lt;test name=&quot;testing post&quot;&gt;
 &lt;classes&gt;
 &lt;class name=&quot;testWordpress.Test_post&quot; &gt;&lt;/class&gt;
 &lt;/classes&gt;
&lt;/test&gt;

&lt;test name=&quot;testing Tag&quot;&gt;
 &lt;classes&gt;
 &lt;class name=&quot;testWordpress.Test_tag&quot; &gt;&lt;/class&gt;
 &lt;class name=&quot;testWordpress.Test_Category&quot; &gt;&lt;/class&gt;
 &lt;/classes&gt;
&lt;/test&gt;


&lt;/suite&gt;

package testWordpress;

import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
public class Test_Base {

@BeforeSuite
 public void LogintoWordPress(){
 System.out.println(&quot;Login to wordpress&quot;);
 System.out.println(&quot;&quot;);
 }

 @AfterSuite
 public void LogoutfromWordPress(){
 System.out.println(&quot;&quot;);
 System.out.println(&quot;Logout from wordpress&quot;);
 }
}

package testWordpress;

import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class Test_Category {
 @BeforeClass
 public void NavigateToCategoryPage(){
 System.out.println(&quot;&quot;);
 System.out.println(&quot;Click on Category page of wordpress-------------&quot;);
 System.out.println(&quot;&quot;);

 }

 @AfterClass
 public void writeStatusToExcel(){
 System.out.println(&quot;&quot;);
 System.out.println(&quot;Write Pass/Fail/Skip status to Excel / HTML report&quot;);
 }

 @BeforeMethod
 public void VerifyExecutionStatus(){
 System.out.println(&quot;&quot;);
 System.out.println(&quot;Verify testcase execution status from excel&quot;);
 ;

 }

 @AfterMethod
 public void WriteStatusToExcel(){

 System.out.println(&quot;Write Testcase Pass/Fail/Skip status to Excel / HTML report &quot;);
 System.out.println(&quot;&quot;);
 }

 @BeforeTest
 public void defineVariables(){
 System.out.println(&quot;-----------------------&quot;);
 System.out.println(&quot;@BeforeTest testing&quot;);
 }

 @Test
 public void AddnewCategory(){
 System.out.println(&quot; Testing Add new Category&quot;);
 }

 @Test
 public void EditCategory(){
 System.out.println(&quot; Testing Edit Category&quot;);
 }

 @Test
 public void ViewCategory(){
 System.out.println(&quot; Testing View Category&quot;);

 }

 @Test
 public void DeleteCategory(){
 System.out.println(&quot; Testing Delete Category&quot;);
 }

 @Test
 public void QuickEditCategory(){
 System.out.println(&quot; Testing Quick Edit Category&quot;);
 }
}

package testWordpress;

import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class Test_post {

@BeforeClass
 public void NavigateToPostPage(){
 System.out.println(&quot;&quot;);
 System.out.println(&quot;Click on post page of wordpress-------------&quot;);
 System.out.println(&quot;&quot;);
 }

 @AfterClass
 public void writeStatusToExcel(){
 System.out.println(&quot;&quot;);
 System.out.println(&quot;Write Pass/Fail/Skip status to Excel / HTML report&quot;);
 }

 @BeforeMethod
 public void VerifyExecutionStatus(){
 System.out.println(&quot;&quot;);
 System.out.println(&quot;Verify testcase execution status from excel&quot;);

 }

 @AfterMethod
 public void WriteStatusToExcel(){

 System.out.println(&quot;Write Testcase Pass/Fail/Skip status to Excel / HTML report &quot;);
 System.out.println(&quot;&quot;);
 }

 @Test
 public void AddNewPost(){
 System.out.println(&quot; Testing Add New post&quot;);
 }

 @Test(dependsOnMethods = { &quot;AddNewPost&quot; })
 public void EditPost(){
 System.out.println(&quot;Edit post Testing&quot;);
 }

@Test(dependsOnMethods = { &quot;EditPost&quot; })
 public void ViewPost(){
 System.out.println(&quot;View post testing&quot;);
 }

 @Test(dependsOnMethods = { &quot;ViewPost&quot; })
 public void QuickEditPost(){
 System.out.println(&quot;Quick Edit post testing&quot;);
 }

 @Test(dependsOnMethods = { &quot;QuickEditPost&quot; })
 public void TrashPost(){
 System.out.println(&quot;Trash post testing&quot;);
 }
}

package testWordpress;

import org.testng.SkipException;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class Test_tag {
 @BeforeClass
 public void NavigateTotagPage(){
 System.out.println(&quot;&quot;);
 System.out.println(&quot;Click on tag page of wordpress-------------&quot;);
 System.out.println(&quot;&quot;);
 }

 @AfterClass
 public void writeStatusToExcel(){
 System.out.println(&quot;&quot;);
 System.out.println(&quot;Write Pass/Fail/Skip status to Excel / HTML report&quot;);
 }

 @BeforeMethod
 public void VerifyExecutionStatus(){
 System.out.println(&quot;&quot;);
 System.out.println(&quot;Verify testcase execution status from excel&quot;);

 }

 @AfterMethod
 public void WriteStatusToExcel(){

 System.out.println(&quot;Write Testcase Pass/Fail/Skip status to Excel / HTML report &quot;);
 System.out.println(&quot;&quot;);
 }

 @Test
 public void AddnewTag(){
 System.out.println(&quot; Testing Add new Tag&quot;);
 }

@Test
 public void EditTag(){
 System.out.println(&quot; Testing Edit Tag&quot;);
 }

@Test
 public void ViewTag(){
 System.out.println(&quot; Testing View Tag&quot;);
 throw new SkipException(&quot;Skipping - This is not ready for testing &quot;);
 }

@Test
 public void DeleteTag(){
 System.out.println(&quot; Testing Delete Tag&quot;);
 }
}

Advertisements
Pupunzi

For a better web

Tech

News and reviews from the world of gadgets, gear, apps and the web

Digital Inspiration

Tips and tutorials around all things tech.

Thinkwareglobal's Blog

Just another WordPress.com weblog

Kenazari's Blog

Just another WordPress.com weblog

Richfowler1's Blog

Just another WordPress.com weblog

Romaicus's Blog

Just another WordPress.com weblog

botlaguduri

Just another WordPress.com site

chandanag89

Just another WordPress.com site

meghshetty

Just another WordPress.com site

digitalmediaexpert

digital media expert blog

Different Journeys

Let's make life easier!

Thinking in Silverlight

Silverlight/WPF/Windows 8 Store App

LAW RESOURCE INDIA

LEGAL RESOURCE CENTRE / COURT JUDGMENTS / LEGAL ARCHIVES

BookConnect

Promoting Indian language Books

Actively Lazy

Software, crafted with passion

SAPonPower

An ongoing discussion about SAP infrastructure

SAP Career

Your Career Mentor

hrsapcertification

Just another WordPress.com site

The secret product manager

Thoughts about product management, SUSE, Linux, ARM processors, Cloud, AIX, Power Systems, and other things that interest me

Simon Les Flex's Blog

SAP Process Integration Specialist - NOW WE CAN DO BETTER!

Oracle Technologies Primer

An Oracle Fusion Middleware and iPaaS blog!

Gilberto Holms

Java, Middleware, SOA Architecture Blog

The Skeleton

Java code skeletons, tips and pointers

J@n van Zoggel

Journal of a tech junkie

The Pragmatic Integrator

Hints and tips from a pragmatic integration specialist

briskwalk

The pace of life..

Optimalbg's Blog

Just another WordPress.com site

IT Jobs in USA

Keep the track of this Blog if you are looking out for some good Opportunities to work in USA....

Referral Jobs | Right Place to Get a Job

Hurry you are one Click away to get a job - Fresher Jobs for 2012, 2013 fresher’s and also high paid jobs for well Experienced IT professionals on Referal jobs.

Michael Korn's Blog

Musings on Life, Career, Faith and Technology

WORKINGWITHQTP

Just another WordPress.com weblog

Topics

.Net Core, AspNetCore, Entity Framework, Entity Framework Core, AspNetIdentity, AspNetIdentityCore, Unit Test, WCF, Workflows

Expertqtp's Weblog

Just another WordPress.com weblog

Sai Chamarthi

Experienced Testing Professional

saxenavinay

A great WordPress.com site

Suresh4qtp's Blog

Just another WordPress.com site

jonah95hill

This WordPress.com site is the cat’s pajamas

It's always something...

Just another WordPress.com weblog

Faculty of Information Technology - Lê Ngọc Tiến

Be Yourself! Simplify Our Goals! Nothing is Impossible!

Anti-Malware Testing

Thoughts on security product testing past and present

Methods & Tools

Practical knowledge for the software developer, tester and project manager

Mindscripts Software Testing Training Institutes In Pune

Software Testing In Pune, Software Testing Training In Pune, Software Testing Training Institute,Software Testing Training Institutes In Pune ,Software Testing Training Centers,Software Testing Classes In Pune,,Software Testing Courses Pune, Software Testing Certification In Pune,,software testing certification course in pune,software testing certification institutes in pune

edington associates

Working with organizations to develop sustainable and thriving workplaces and people.

Enterprise WordPress hosting, support, and consulting - WordPress VIP

Our best-in-class enterprise WordPress hosting platform, expert consulting and support, and diverse partner ecosystem free you to focus on your business objectives.

WORK Online

Virtual Office at HOME