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.