UrbanPro
true

Learn Cucumber (Tool) Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Script we have to write even before hooks in cucumber

S
Sarthak C.
27/11/2019 0 0

In Cucumber, we have Before & After hook – it will run before and after each scenarios.

Problem Statement: What if we have to open the database connectivity (only once) before executing the scenarios and closing the connection (only once) after running all scenarios.

One of the Solution – We can use @BeforeClass and @AfterClass (junit annotations) in Runner Class which will run once.

 

Refer Below Runner Class:

 

@RunWith(Cucumber.class)

@CucumberOptions(

 features = "src\\Test1.feature",

 glue={"stepDefinition"}

 )

public class RunnerClass {

 

 

@BeforeClass

public static void beforeclass() {

System.out.println("beforeClass");

    }

}

@AfterClass

public static void afterclass() {

System.out.println("afterClass");

     }

}

0 Dislike
Follow 1

Please Enter a comment

Submit

Other Lessons for You

Priority in TestNG
public class Priority { @Test (priority=1)public void login() {System.out.println("login");} @Testpublic void email1() {System.out.println("email1");} @Test (priority=-2)public void email2() {System.out.println("email2");} //I...
S

Sarthak C.

0 0
0

Constructor Overloading
public class ConstructorOverloading { public ConstructorOverloading(){ System.out.println("default"); } public ConstructorOverloading(String a){ System.out.println("a"); } public ConstructorOverloading(int...
S

Sarthak C.

0 0
0

doWhile example in Java
public class doWhilePracticleEx { public void test() { } public static void main(String args) { String q1 = "Who is PM of India?"; String a1 = "Sonia Gandhi"; String a2 = "Rahul Gandhi"; String a3...
S

Sarthak C.

0 0
0

CheatSheet for xpath/css used in Selenium (UI Automation Testing)
Locators Dynamic XPath String a = "//html/body/div/header/nav/div/div/ul/li/div/div/span/div/div/div"; String xp = a + i + b; =========================================== ...
S

Sarthak C.

0 0
0

How to Read Data From Property File
1. Create a property file using New > File > Given name - like config.properties (it must be saved with .properties). 2. Add data in config.properties like: browser = chrome environment = qa 3....
S

Sarthak C.

0 0
0

Looking for Cucumber (Tool) Training ?

Learn from Best Tutors on UrbanPro.

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Cucumber (Tool) Training Classes?

The best tutors for Cucumber (Tool) Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Cucumber (Tool) Training with the Best Tutors

The best Tutors for Cucumber (Tool) Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more