What is the use of @Rule annotation in JUnit?

0 votes
Jun 19, 2019 in Selenium by Sarfaraz
136 views

1 answer to this question.

0 votes

Hello Sarfaraz, JUnit provides special kind of handling of tests or test suite by using @rule annotation. By using @rule, you can easily add or redefine the behavior of the test. There are several built-in rules provided by JUnit API that a tester can use, or even you can write our own rule. Following line of code shows how to use @rule annotation along with Error Collector:

@Rule				
public ErrorCollector collector= new ErrorCollector();
answered Jun 19, 2019 by anonymous
• 27,760 points

Related Questions In Selenium

0 votes
1 answer

What is the use of @listener annotation in TestNG?

 @listeners are used to configure reports and ...READ MORE

answered Jan 2, 2019 in Selenium by Shuvodip
589 views
0 votes
1 answer

What is the role of TestNG & JUnit frameworks in Selenium?

Well TestNG and JUnit are test frameworks ...READ MORE

answered Apr 18, 2018 in Selenium by king_kenny
• 3,690 points
447 views
0 votes
1 answer

What is the use of grouping in testNG?

Grouping is the method used to separate ...READ MORE

answered Dec 26, 2018 in Selenium by Trisha
144 views
0 votes
1 answer

What is the use of Sibling in Xpath?

Using sibling keyword, we can fetch a ...READ MORE

answered Jan 9, 2019 in Selenium by Frankie
• 9,810 points
376 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,510 points
1,579 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,870 points
1,504 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,870 points
1,293 views
0 votes
1 answer

What is the use of getOptions() method in Selenium?

Hi Urmila, getOptions() is used to get all ...READ MORE

answered May 31, 2019 in Selenium by Abha
• 27,760 points
1,594 views
0 votes
1 answer

What is the use of invocationcount in TestNG?

Hey Owen, The invocationcount attribute tells how many ...READ MORE

answered Jun 19, 2019 in Selenium by anonymous
• 27,760 points
762 views