How To Preserve Order Of Execution

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
€65.24
List Price:  €93.20
You save:  €27.96
£55.93
List Price:  £79.91
You save:  £23.97
CA$95.58
List Price:  CA$136.56
You save:  CA$40.97
A$107.13
List Price:  A$153.05
You save:  A$45.92
S$95.25
List Price:  S$136.08
You save:  S$40.82
HK$547.90
List Price:  HK$782.75
You save:  HK$234.85
CHF 63.85
List Price:  CHF 91.21
You save:  CHF 27.36
NOK kr770.13
List Price:  NOK kr1,100.23
You save:  NOK kr330.10
DKK kr486.51
List Price:  DKK kr695.05
You save:  DKK kr208.53
NZ$117.65
List Price:  NZ$168.07
You save:  NZ$50.42
د.إ257.06
List Price:  د.إ367.25
You save:  د.إ110.18
৳7,679.19
List Price:  ৳10,970.75
You save:  ৳3,291.55
₹5,834.32
List Price:  ₹8,335.10
You save:  ₹2,500.78
RM333.81
List Price:  RM476.90
You save:  RM143.08
₦91,422.33
List Price:  ₦130,608.93
You save:  ₦39,186.60
₨19,487.31
List Price:  ₨27,840.21
You save:  ₨8,352.89
฿2,585.90
List Price:  ฿3,694.31
You save:  ฿1,108.40
₺2,277.50
List Price:  ₺3,253.72
You save:  ₺976.21
B$361.10
List Price:  B$515.88
You save:  B$154.78
R1,320.17
List Price:  R1,886.05
You save:  R565.87
Лв127.48
List Price:  Лв182.13
You save:  Лв54.64
₩96,293.43
List Price:  ₩137,567.94
You save:  ₩41,274.51
₪266.53
List Price:  ₪380.78
You save:  ₪114.24
₱4,038.21
List Price:  ₱5,769.12
You save:  ₱1,730.90
¥10,975.59
List Price:  ¥15,680.08
You save:  ¥4,704.49
MX$1,206.90
List Price:  MX$1,724.22
You save:  MX$517.31
QR255.26
List Price:  QR364.68
You save:  QR109.41
P965.80
List Price:  P1,379.77
You save:  P413.97
KSh9,448.65
List Price:  KSh13,498.65
You save:  KSh4,050
E£3,352.63
List Price:  E£4,789.68
You save:  E£1,437.04
ብር3,985.10
List Price:  ብር5,693.24
You save:  ብር1,708.14
Kz58,489.70
List Price:  Kz83,560.30
You save:  Kz25,070.60
CLP$66,385.51
List Price:  CLP$94,840.51
You save:  CLP$28,455
CN¥507.19
List Price:  CN¥724.59
You save:  CN¥217.40
RD$4,111.01
List Price:  RD$5,873.12
You save:  RD$1,762.11
DA9,398.61
List Price:  DA13,427.17
You save:  DA4,028.55
FJ$158.17
List Price:  FJ$225.97
You save:  FJ$67.79
Q544.39
List Price:  Q777.73
You save:  Q233.34
GY$14,639.41
List Price:  GY$20,914.34
You save:  GY$6,274.92
ISK kr9,791.60
List Price:  ISK kr13,988.60
You save:  ISK kr4,197
DH708.11
List Price:  DH1,011.63
You save:  DH303.52
L1,243.72
List Price:  L1,776.81
You save:  L533.09
ден4,016.98
List Price:  ден5,738.79
You save:  ден1,721.81
MOP$563.94
List Price:  MOP$805.67
You save:  MOP$241.72
N$1,340.22
List Price:  N$1,914.68
You save:  N$574.46
C$2,575.16
List Price:  C$3,678.96
You save:  C$1,103.79
रु9,316.74
List Price:  रु13,310.19
You save:  रु3,993.45
S/261.07
List Price:  S/372.97
You save:  S/111.90
K269.52
List Price:  K385.04
You save:  K115.52
SAR262.50
List Price:  SAR375.02
You save:  SAR112.51
ZK1,842.03
List Price:  ZK2,631.59
You save:  ZK789.55
L324.63
List Price:  L463.78
You save:  L139.14
Kč1,640.70
List Price:  Kč2,343.96
You save:  Kč703.26
Ft25,605.88
List Price:  Ft36,581.40
You save:  Ft10,975.51
SEK kr762.91
List Price:  SEK kr1,089.92
You save:  SEK kr327.01
ARS$61,153.48
List Price:  ARS$87,365.86
You save:  ARS$26,212.38
Bs484.56
List Price:  Bs692.26
You save:  Bs207.70
COP$275,828.59
List Price:  COP$394,057.74
You save:  COP$118,229.14
₡35,172.98
List Price:  ₡50,249.28
You save:  ₡15,076.29
L1,727.65
List Price:  L2,468.18
You save:  L740.53
₲519,796.34
List Price:  ₲742,598.03
You save:  ₲222,801.68
$U2,684.12
List Price:  $U3,834.62
You save:  $U1,150.50
zł281.95
List Price:  zł402.81
You save:  zł120.85
Already have an account? Log In

Transcript

Hello all welcome back to the next one. In this one we'll see how we can control the order of execution from the test Angie XML file. Let me just quickly bring up Eclipse and here I have created two files. First one is test Angie underscore preserve one and the second one is test engine the scope is up to and we have couple of methods here. First one is test method one test method two and the method name is same in both the classes. So I changed the print statement This one is coming from preserve one class and right here and this one is coming from presser to class right.

So we can identify from which test class these statements are coming. Then I created one XML file, named it as preserve enabled test suite. And test name is test one included both the classes here. Test classes dot testan g underscore preserve two and preserve one So let's just try to run this one from XML file. And let's see how they are run. And then we will see how we can control the order.

So run as test in G Suite. And it ran preserve two test method one, preserve two, test method two and both the methods in the same order. And the prisoner to class was one before and then preserve one class was one. And this is the order in which we named the classes. Now let's take a look at preserve order tags, so I'm just going to hit control space, preserve order, by default, it's kind of true. So I'm just gonna make it false right now.

So it just goes with the test, attribute test and you can say, and now I saved the file. And let me just right click and run and again so As soon as I run it this time, you can see the difference that test mg underscore preserved one class this class was run before test engine the score preserved. And I think what happened is right now testing they started to picking up the class with the name because preserve one comes before preserve to ascending order. So I just picked it up. But that's happening because we said preserve order falls. This guy if we say it as crew, and then just right click run as test in G Suite.

It will preserve the order preserve order means in the order we specified the test classes, test nj will honor that and it will take that into account while running the test cases. So basically, if we provide this attribute preserve order as true order will be preserved. Now let's take a look. So in a suite, we can actually mention multiple test. So this is one block of code, we can actually copy this and mention it. And let's name it as test two.

And let's just delete this one from here. And maybe we'll just run one after class or it's okay to run both of the classes also. So we obviously, there might be scenarios where you want the same classes to run in a different configuration and test this test can have completely different configurations. And you'll see these things in some other lectures where we'll talk about parameters and other stuff. But for now, let's understand that we have multiple test under one suite. And these classes could be same or different that it's okay, it doesn't matter.

Right now we're trying to figure out how we can enable or disable one of the suite. Let's say I don't want to delete In this whole block from here, and temporarily, I want to disable one of the test. That's it, because deleting is kind of destructive. And if I have to add it again, there's a lot of work, right? So sometimes there are scenarios where we just want to disable a suite or disable a test. And we don't want to delete it.

So what we can do here is we can use enabled attribute here. and enable is true by default, I can just give it false. And if I saw, okay, let me just put it true for the first time. So what's gonna happen here is we will see the same output twice. We have to test with the same classes. So we should be seeing the same output twice.

I'm going to run as test in G Suite. And that's what I see here. Preserve to the sky, then preserve one against the preserve two, right here. And then I again see preserve one, and it tells us that a test will run. And in this place also we can see this class. So there are two tests now.

So test one and test two, we have defined them here test one, test two. And then we can see test one has preserved two and preserve one test Angie underscore, I'm just not naming the full class name. And then this one again has preserved to preserve one this can have different classes also, that's a different thing. But what we are trying to say here is we have two different tests and both were run at this time. Now what I can do here is I can disable it by saying enable equals to false. And I'm gonna save this file.

Sometimes you can see this error if you don't save the file, so just save the file and then right click this one and run as the and sweet. And we see the execution only once. And if we go to the Results tab of test Angie, we see only test one was executed, there is no test to write. So what we did is we disabled the test to this block of code we disabled. And we can actually do it very easily just with the use of an attribute. So it's very helpful.

Sometimes we don't want to delete the complete thing. And we are showing here simple scenario with just two class names. You could have like 1020 class names, you don't want to delete everything. You may want to temporarily disable something because of some issue or anything related to the product. So this is a very helpful tag. That's about it.

For this one, please practice it, download the code files. Let me know if you have any questions and I'll see in the next lectures. Thanks for attending this one.

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.