ISuiteListener

6 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€59.53
List Price:  €85.05
You save:  €25.51
£52.19
List Price:  £74.56
You save:  £22.37
CA$96.41
List Price:  CA$137.74
You save:  CA$41.32
A$105.49
List Price:  A$150.71
You save:  A$45.21
S$90.27
List Price:  S$128.96
You save:  S$38.69
HK$544.44
List Price:  HK$777.80
You save:  HK$233.36
CHF 55.69
List Price:  CHF 79.57
You save:  CHF 23.87
NOK kr711.80
List Price:  NOK kr1,016.90
You save:  NOK kr305.10
DKK kr444.77
List Price:  DKK kr635.42
You save:  DKK kr190.64
NZ$121.02
List Price:  NZ$172.90
You save:  NZ$51.87
د.إ257.03
List Price:  د.إ367.21
You save:  د.إ110.17
৳8,551.02
List Price:  ৳12,216.27
You save:  ৳3,665.24
₹6,369.99
List Price:  ₹9,100.38
You save:  ₹2,730.38
RM285.94
List Price:  RM408.50
You save:  RM122.56
₦101,634.57
List Price:  ₦145,198.47
You save:  ₦43,563.90
₨19,609.48
List Price:  ₨28,014.74
You save:  ₨8,405.26
฿2,206.14
List Price:  ฿3,151.76
You save:  ฿945.62
₺2,989.46
List Price:  ₺4,270.85
You save:  ₺1,281.38
B$378.96
List Price:  B$541.40
You save:  B$162.43
R1,175.86
List Price:  R1,679.87
You save:  R504.01
Лв116.42
List Price:  Лв166.33
You save:  Лв49.90
₩103,198.16
List Price:  ₩147,432.26
You save:  ₩44,234.10
₪225.14
List Price:  ₪321.65
You save:  ₪96.50
₱4,102.27
List Price:  ₱5,860.63
You save:  ₱1,758.36
¥10,837.05
List Price:  ¥15,482.17
You save:  ¥4,645.11
MX$1,257.56
List Price:  MX$1,796.59
You save:  MX$539.03
QR255.01
List Price:  QR364.32
You save:  QR109.30
P924.12
List Price:  P1,320.23
You save:  P396.11
KSh9,021.71
List Price:  KSh12,888.71
You save:  KSh3,867
E£3,317.57
List Price:  E£4,739.60
You save:  E£1,422.02
ብር10,890.43
List Price:  ብር15,558.42
You save:  ብር4,667.99
Kz63,853.85
List Price:  Kz91,223.69
You save:  Kz27,369.84
CLP$63,993.95
List Price:  CLP$91,423.85
You save:  CLP$27,429.90
CN¥492.84
List Price:  CN¥704.09
You save:  CN¥211.25
RD$4,444.65
List Price:  RD$6,349.77
You save:  RD$1,905.12
DA9,071.82
List Price:  DA12,960.30
You save:  DA3,888.48
FJ$157.74
List Price:  FJ$225.35
You save:  FJ$67.61
Q536
List Price:  Q765.75
You save:  Q229.74
GY$14,638.82
List Price:  GY$20,913.50
You save:  GY$6,274.67
ISK kr8,822.93
List Price:  ISK kr12,604.73
You save:  ISK kr3,781.80
DH642.26
List Price:  DH917.55
You save:  DH275.29
L1,178.68
List Price:  L1,683.90
You save:  L505.22
ден3,665.09
List Price:  ден5,236.07
You save:  ден1,570.98
MOP$560.91
List Price:  MOP$801.33
You save:  MOP$240.42
N$1,173.99
List Price:  N$1,677.20
You save:  N$503.21
C$2,575.18
List Price:  C$3,678.99
You save:  C$1,103.80
रु10,153.72
List Price:  रु14,505.95
You save:  रु4,352.22
S/235.62
List Price:  S/336.62
You save:  S/100.99
K297.36
List Price:  K424.81
You save:  K127.45
SAR262.55
List Price:  SAR375.09
You save:  SAR112.54
ZK1,621.58
List Price:  ZK2,316.65
You save:  ZK695.06
L303.11
List Price:  L433.04
You save:  L129.92
Kč1,448.60
List Price:  Kč2,069.52
You save:  Kč620.92
Ft22,916.77
List Price:  Ft32,739.64
You save:  Ft9,822.87
SEK kr650.99
List Price:  SEK kr930.02
You save:  SEK kr279.03
ARS$100,664.40
List Price:  ARS$143,812.45
You save:  ARS$43,148.05
Bs485.26
List Price:  Bs693.25
You save:  Bs207.99
COP$265,564.41
List Price:  COP$379,394
You save:  COP$113,829.58
₡35,000.95
List Price:  ₡50,003.51
You save:  ₡15,002.55
L1,843.07
List Price:  L2,633.07
You save:  L790
₲469,954.11
List Price:  ₲671,391.79
You save:  ₲201,437.68
$U2,738.16
List Price:  $U3,911.83
You save:  $U1,173.66
zł251.44
List Price:  zł359.21
You save:  zł107.77
Already have an account? Log In

Transcript

Hello all welcome back to the next one. In this one, we'll take a look at one more Lesnar from testan G, and that is I sweet listener. So we looked at I invoke method listener, we looked at I test listener, since we had things on methods and test level, we should have something on the level of suite as well, right? Because there might be stuff that we want to run and execute before and after suites. So what is a test suite? We all know in our XML files, we have a suite tag, and under that we have multiple test tags.

So this is the suite level. What I've done here is I've just made a small change that here I'm running test listener, test one, and here I'm learning running test listener, sorry, listener, test two. And then I have two classes here. The first one was using customers. Number one, the second one was using custom listener to, we will actually change both of them to use custom listener three. So let's go ahead in our listeners package, rb one of them and create a custom listener three class.

And let's open it. I'm going to delete the custom listener one stuff. And I'm going to delete this interface as well. So now we will use ice sweet. And then control space I sweet listener from our dot test. And now let's implement the unimplemented methods.

So click on this and it's a very easy one. So there are only two methods inside it. On start and on finish, and we got the imported statements here, right. So always make sure we have correct import statements. Then it is very easy, right? We can just tell by name also OnStar is when the sweet start the suite level and on finishes when sweetens, right, so let's write the comments here.

When sweet tag starts. And same thing when sweet tag completes. That's about it. So this is very easy. Let's write couple of print statements to understand it. So this is coming from onstart.

And this is coming from on finish. Let me just write it So let's write it maybe when, okay, I have to write it within the double quotes. So before sweet starts. And we can just write the same thing. Here after sweet completes. That's it.

Now, what I want to do here is I want the same listener in both these classes. We have one more way to use listener, instead of importing the listener package here, and providing the listener annotation here, we can actually do the same thing directly from our XML file. And it's very easy because then we do not have to change it or add it separately in every class file. So let's see how we can do it. I'm just gonna Delete. Or maybe you know what, let's not delete, let's comment out the things.

And I'm gonna comment out the import statement as well. And this one, I can come delete, because we're not using the custom listener here. The same thing I'm going to do here, let's comment out. Let's comment out this listener as well. And let's delete the custom listener. So now we have both the classes all said and done, but we need to tell them some way that please refer to custom listener three when you are running.

So we will go to our XML file, and we can see we have both the test tags in the suite level before the test tag itself, we can just mention it here. So I'm going to start this and listeners. So here inside it, we can add a listener. So listener, and that's done now We need to tell which listener we want to use. So I'm gonna, I want to use custom listener three. So let's copy the package name, and then the class name here, because we always have to tell the package name.

What's gonna happen here is destiny is gonna notice this thing. And it's gonna figure out that this sweet listeners test suite, it uses a listener with the name, custom listener, three, and all the test tags, all the classes inside it will use the same listener. And that's pretty interesting. Right? And it's pretty easy, because then now we don't have to add them here in every test class. That's done all surrender.

Now let me just go ahead and right click the XML file and run it. So run as test in G Suite. And here we go. Failing one method because we already know we're failing one method intentionally. So, the first thing that happened was on start executed before so it starts all the methods executed from both the classes. So from listener test one all the methods executed then from listeners to all the methods executed.

And then on finish executed at the sweet level. So after sweet completes, that's about it. This sweet listener is very simple, very easy to understand, very easy to learn. So guys, please go ahead and download the code file, practice it and let me know if you have any questions. I'll see you in the next lecture.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.