Right.
So now how to run the tests in cucumber terminology.
Running the test means running the feature file.
This is our test in cucumber, so we call it as a running the feature file.
So for that, there is something called test runner.
So which you want to create.
So that let's create under this cucumber package itself.
And again, you have to question yourself what kind of runner you want to create.
Do you want to create?
J Unit runner or test runner?
So that depends upon what framework your project is using internally.
So now we are on testing the framework, which is obvious, right?
So if you see here all these assertions, annotations.
So cucumber does not care about all this, but still inside your code.
Also, if you go to step definition methods, you have some assertions, right?
So these assertions are nothing but testing.
So if your code is driven by test energy, then you need to create test energy.
Cucumber runner.
If it is driven by J unit j and it is just another framework like test energy.
Both are complements against each other, but it is like they are from long time and test energy is
something new and very widely used in testing frameworks.
Mostly you see test energy only in companies, right?
So that's where we have written.
So that means we have to create a test energy runner for cucumber.
That's okay.
We can do it.
So just start with one class name and call it as a test and g test runner.
So here where you have to give the information about running your cucumber feature files.
So there is some standard of doing that.
So by default, you know, the test run or what you have done to run your feature files by default,
if you create a class like this and ask to run feature files, it does not work.
You need to provide a lot of options here.
So all the options you can provide by defining this cucumber options tag.
Using this tag, there are a lot of helper attributes where you need to provide.
It's like guys at the rate test in test energy you have at the rate test and instead you provide groups
depends on methods.
Three Try all things to provide as a helper attributes right inside the test.
Right?
You provide like this similarly for your test run or also if you want to run cucumber test, you have
to start with cucumber option stack and provide which feature file to run all this inside this brackets.
So first hover your cursor and import this cucumber options, right?
So first thing is features what feature files you want to run that feature files path you have to provide
here.
So there is a path of your feature files.
It's in sauce test, java, cucumber insert.
This feature file is there.
Right.
So source.
Best Java Cucumber perfect.
So from project level, this is the part where I can find my feature files because I have to clearly
tell to your runner that where future files are there to run.
If not, it cannot understand.
And next for this future files, we are linking up with the step definition file.
Right.
So your runner also should know where is your step definition file so that for mapping it goes to that
path and map your feature steps.
So your step definition file path can be given with the help of glue attribute.
When you set glow attribute to the package of your step definitions, then you run out, understand
where it is.
So it is in the academy dot step definitions, right?
So make sure you have it in the codes here.
Perfect.
So you have given directories where you are, feature files are there where your glue file is there
and next thing by default, you know, the output of your cucumber will come in encoded format that
results will not be in readable.
So what you can do there is one attribute called monochrome in cucumber, which will give the results
in readable format.
So that's the default one people will set to read the report.
And how do you want to generate the report?
If you want HTML report for that, you have to pull that plugin.
So cucumber guys provide plugins for reporting.
So now if you want his HTML report plugin equals to and here where you need to define HTML is the report
I want and where that has to stored, you have to give it in key value pairs.
All plugin information has to be in key value pairs.
So key is like what kind of report you want and value is let's say I want it in target slash cucumber
dot html.
So target folder will be created for you automatically when you run your maven project.
So make sure you give that information in the courts.
Perfect.
So basically, you are telling that run all feature files present in this package and to map them here
is mere step definitions.
Are there print the results in readable format and generate the report of HTML plugin.
So these are the different helper attributes you are giving and by default, cucumber will not be able
to scan your testing assertions or your testing libraries.
So what you can do is these test NZ guys to provide seamless integration with cucumber.
They created one class called abstract testing cucumber tests.
If you go to their official documentation, you will see that.
So in Build Cucumber do not have the power of scanning your testing code, right?
But if you are a cucumber runner file extends this class over your cursor and change to yeah, this
is the correct name.
If you extend this parent class then you are getting all the capabilities what this parent class provides.
So in this parent class they have written lot of wrapper so that your cucumber can understand and run
the code where testing is there.
So if you are running using Jay on it, then this is not required because by default cucumber have the
ability to run the tests which have j unit code.
It comes an inbuilt, but testing is not something which comes in built in cucumber.
So that's why test NZ guys have created a class and asked cucumber to hey, if you can extend my wrapper
class then you know what, you will be able to read me.
So that's the beauty of open source, right?
You can seamlessly integrate different tools and if you want to know the code, go inside and there's
a lot of things will be there, like how to wrap everything that's not required for us.
The official documentation itself says that just extend this keyword and you should be good to run your
test in the tests.
And next thing, if you wonder, like, how would I know that glue is for step definition, future size
for this is the key value.
What I have to use go to this cucumber options and here you have a lot of features.
Help see this glue.
This is what I have used and features all this you can read here and understand why these are required.
Awesome.
So your runner is ready now.
So if I run this, what happens is first it will scan all the future files present in this folder and
it will trigger one by one.
So in our case right now in this folder, only one feature file is there, which is enter and submit
the order and it will trigger that without any hassle.
Let's see.
I'll just right click on this test runner run as you can still run it as a test energy test only.
But here you are executing cucumber feature.
Right.
That is what you need to know.
So.
Yeah.
Here you go.
The one what is now getting executed is the cucumber feature file.
And the same way how it got executed previously with the test z XML files and test annotations.
Same thing.
Now it is happening with future file level.
Awesome.
Your execution is done.
Looks like you need to put a driver clause code at the end.
Once you're done with that.
So here where you can run your test using cucumber feature files.
So if you see on high level, we are just adding one more wrapper for your already existing test energy
tests.
So if someone in your company asks that, can we move to cucumber from any existing framework?
Just let them know that it's not really a big deal.
We just need to add one more wrapper in a plain English gherkin language where you can do like this
and you can showcase them like this.
Let them see this code but back end.
Without much affecting your framework, you are still using the same core concepts of your framework
and making it compatible for both cucumber and the test energy.
Right.
So that is one way, smart way of handling the frameworks.
Or you can exclusively write entire project on cucumber without even using any test.
Okay, that's whole different story.
For that, you have to take my another course where I have in-depth explained at least 8 to 10 hours
on each and every cucumber concept.
And there I went into a lot of advanced concepts as well.
But here the scope of this course is to make sure to convert and make your hybrid framework compatible
with Cucumber also, which we are doing here by touching all main level concepts.
Great.
So in the next lecture, let's quickly convert this test as well.
Let's have two future files so that it feel good to wrap up.
This topic will take just 510 minutes to wrap up this landing page code, and we will include that.
And I'll also show how to control the tests like test energy.
You have groups right in cucumber.
We have a concept called tags where you can control and run selective tests based on the taxi provided.
We'll see that.
Thank you.