Hello Raghav, Your videos helped me a lot to get a JOB in Accenture as "Test Automation lead" 7 months before . and am so happy in my work . If i have some doubts on any area I come back and refer your video again :)
One interesting point. If you have methods annotated with BeforeTest,BeforeSuite etc they will not be run automatically if they are not included in the groups also. If we want the setup and tear down methods to run irrespective of your group classifications we could use alwayrun=true for the Before and after methods
There is a typo in d test for Regression vs xml not sure if exclude worked correctly. vl hv to check ourselves to see.. You r doing good job.. Thanks for d content..
There is a type on the multiple group example. If a test method belongs to both included and excluded group, the excluded group takes the priority and the test method will be excluded from the test execution.
Hello Raghav, I was wondering if its possible to execute certain tests only when the combination of groups match. For example, if one test has groups as "app" and "sanity" And There are other test methods present as well in the project/class. I want to executive tests which have "app" And "sanity" tags only and tests which have only app or sanity tags shouldn't run, is this possible? If so could you share some reference please? Thank you in advance.
Hi Dinesh, you can create a separate testng.xml file and in that include the groups you need, So when you run this file, only the included groups will execute This link has good examples - www.javatpoint.com/testng-groups
Thanks for another great video. There's something I'm stuck on. I have a class with multiple tests in it as per your example here. The results that get reported on the HTML report say the number of tests run is 1. It equates running one class with running one test when it reports. Is it possible to get it to report three tests run when I run one class with three tests in it, as per your example?
Phil Yes, it is possible to get your test report to report three tests run when you run one class with three tests in it. To do this, you need to use a different test reporting tool. The default test reporting tool in Selenium Java is the JUnit test runner. The JUnit test runner only reports the number of test classes that were executed, not the number of test methods. To get a more detailed test report, you can use a different test reporting tool, such as TestNG or Allure Report. TestNG and Allure Report can both report the number of test methods that were executed, as well as the number of test classes. To use TestNG or Allure Report with Selenium Java, you need to add the appropriate dependency to your project. You can do this using Maven or Gradle. Once you have added the TestNG or Allure Report dependency to your project, you need to configure your test classes to use the appropriate test runner. To do this, you can use the `@Test` annotation. Here is an example of how to configure a test class to use the TestNG test runner: ```java import org.testng.annotations.Test; public class MyTestClass { @Test public void test1() { // ... } @Test public void test2() { // ... } @Test public void test3() { // ... } } ``` To run your test class using TestNG, you can use the following command: ``` testng MyTestClass.java ``` To run your test class using Allure Report, you can use the following command: ``` allure generate allure-results --clean -o allure-report ``` Once you have run your test class, you can view the test report in your web browser. The test report will show you the number of test methods that were executed, as well as the number of test classes. I hope this helps
@@RaghavPal Thank you so much for your detailed reply. What you wrote is what you showed in your video. That uses TestNG and so did I. When I open the html report it says 1 test was run despite it being 3 tests in 1 class. It reports class numbers and calls them tests while not reporting actual test numbers. That is TestNG doing that. I think it's because in the .xml file that class sits in a single tag. I need multiple such tags with different classes in them to show I want multiple tests reported. By doing that, I get multiple browser windows opening which is slower and potentially overloads the computer if I have hundreds of tests. My guess it what I'm hoping for is just not how TestNG works. I don't know why though. It seems fairly obvious to me that a class is not the same thing as a test, yet that's how it's categorised in the html report.
Hi Raghav..Thank u for the amazing content. Is it possible to control test case execution from datasheet instead of groups. Like can we provide in the datasheet with a column named"Execution Required" with value"Y/N" for each test case name.
what if there one group defined at class level . but one of method inside that class we are excluding it from testng.xml now if we run class will it run that method too? because method we are excluding but it is still under that class???
Hi Basir, you should be able to run them using testng.xml file. There are some videos to help - ua-cam.com/play/PLhW3qG5bs-L8oRay6qeS70vJYZ3SBQnFa.html
Hi Raghav, Very good explanation. I have one question, something like this we can using "Batch" in testNG. What is the difference between batch and groups and when to use which one ?
Hello sir, my groups does not work if we have before annotation , non of the before annotation execute if we do grouping . any solution other than Always = true?
Hi, I checked online and looks like enabling the attribute alwaysRun=true is the solution for this. I will check more and update if I find anything on this stackoverflow.com/questions/46405840/before-suite-and-beforetest-methods-are-not-called-if-groups-are-executed-in-t
Hi Raghav, Here you have all @test annotation in a single class file. My question is if there are... lets say 100 class files, then does all need to be included in class tag ...can we have groups for classes?
What is the difference by adding groups in test level vs suite level...Even though you explained in words ...I am not getting that part. Please explain with some example while reply .Thanks!
Hello Raghav, Your videos helped me a lot to get a JOB in Accenture as "Test Automation lead" 7 months before . and am so happy in my work . If i have some doubts on any area I come back and refer your video again :)
All the best Shafeek
One interesting point. If you have methods annotated with BeforeTest,BeforeSuite etc they will not be run automatically if they are not included in the groups also. If we want the setup and tear down methods to run irrespective of your group classifications we could use alwayrun=true for the Before and after methods
Thanks for the inputs Ashes
Thank you !!! i don't even want to know how long i would be trying to find out, whats wrong .. again... 🤬😅
Very neat and crisp explanation.. Very good job.
Thanks for watching Prashanth
Thanks for watching Prashanth
There is a typo in d test for Regression vs xml not sure if exclude worked correctly. vl hv to check ourselves to see..
You r doing good job.. Thanks for d content..
Hi Ravi, will check it. Thanks for your message
@@RaghavPal It got excluded.
really wonderfull series...very much seful to me...thank u
You are most welcome
There is a type on the multiple group example. If a test method belongs to both included and excluded group, the excluded group takes the priority and the test method will be excluded from the test execution.
Thanks for info addition
Excellent!!
thanks
Thank you for in detail explained.
You are welcome Smita
Very good👍
Thank you very much
This actually was useful ! Thank you very much for making this video and this playlist.
You're welcome Tahayari
great explaination
Thanks Mahendra
Hello Raghav,
I was wondering if its possible to execute certain tests only when the combination of groups match. For example, if one test has groups as "app" and "sanity" And There are other test methods present as well in the project/class. I want to executive tests which have "app" And "sanity" tags only and tests which have only app or sanity tags shouldn't run, is this possible? If so could you share some reference please?
Thank you in advance.
Hi Dinesh, you can create a separate testng.xml file and in that include the groups you need, So when you run this file, only the included groups will execute
This link has good examples - www.javatpoint.com/testng-groups
very nice and clear thanks a lot...
You're welcome Chandra
God Bless you my friend
Thanks for the wishes Towhid
Nice Explanation sir
Thanks Dipankar
Hello Raghav, thanks for the above,
clarification - can we club groups+parameters for parallel testing on testng.xml and run them
Hi Pradeep, you should be able to do that. Pls try
Thank you
You're welcome Shafeek
Thanks for another great video. There's something I'm stuck on. I have a class with multiple tests in it as per your example here. The results that get reported on the HTML report say the number of tests run is 1. It equates running one class with running one test when it reports. Is it possible to get it to report three tests run when I run one class with three tests in it, as per your example?
Phil
Yes, it is possible to get your test report to report three tests run when you run one class with three tests in it. To do this, you need to use a different test reporting tool.
The default test reporting tool in Selenium Java is the JUnit test runner. The JUnit test runner only reports the number of test classes that were executed, not the number of test methods.
To get a more detailed test report, you can use a different test reporting tool, such as TestNG or Allure Report. TestNG and Allure Report can both report the number of test methods that were executed, as well as the number of test classes.
To use TestNG or Allure Report with Selenium Java, you need to add the appropriate dependency to your project. You can do this using Maven or Gradle.
Once you have added the TestNG or Allure Report dependency to your project, you need to configure your test classes to use the appropriate test runner. To do this, you can use the `@Test` annotation.
Here is an example of how to configure a test class to use the TestNG test runner:
```java
import org.testng.annotations.Test;
public class MyTestClass {
@Test
public void test1() {
// ...
}
@Test
public void test2() {
// ...
}
@Test
public void test3() {
// ...
}
}
```
To run your test class using TestNG, you can use the following command:
```
testng MyTestClass.java
```
To run your test class using Allure Report, you can use the following command:
```
allure generate allure-results --clean -o allure-report
```
Once you have run your test class, you can view the test report in your web browser. The test report will show you the number of test methods that were executed, as well as the number of test classes.
I hope this helps
@@RaghavPal Thank you so much for your detailed reply. What you wrote is what you showed in your video. That uses TestNG and so did I. When I open the html report it says 1 test was run despite it being 3 tests in 1 class. It reports class numbers and calls them tests while not reporting actual test numbers. That is TestNG doing that. I think it's because in the .xml file that class sits in a single tag. I need multiple such tags with different classes in them to show I want multiple tests reported. By doing that, I get multiple browser windows opening which is slower and potentially overloads the computer if I have hundreds of tests.
My guess it what I'm hoping for is just not how TestNG works. I don't know why though. It seems fairly obvious to me that a class is not the same thing as a test, yet that's how it's categorised in the html report.
may be the case, if I get to know more on this will share
@@RaghavPal Thank you. I really appreciate your fantastic channel. 👍
excellent
Thanks for watching Divyang
Hi Raghav..Thank u for the amazing content. Is it possible to control test case execution from datasheet instead of groups. Like can we provide in the datasheet with a column named"Execution Required" with value"Y/N" for each test case name.
Yes, Puja you can do, will have to add script for that
love u bro thanx thanx..
You're welcome Biren
Hi Raghav. Thanks for the video.
Need help on this. I want to take group tags from my properties file. How to achieve that.
Hi Amit, are you talking about parameterising the tags. Will need to check online
what if there one group defined at class level . but one of method inside that class we are excluding it from testng.xml
now if we run class
will it run that method too?
because method we are excluding but it is still under that class???
Hi Divyang, I will need to try this. Can you try and check what happens
Thank you. Q? How to execute test cases from multiple classes using group?
Hi Basir, you should be able to run them using testng.xml file. There are some videos to help - ua-cam.com/play/PLhW3qG5bs-L8oRay6qeS70vJYZ3SBQnFa.html
Hi Raghav, Very good explanation.
I have one question, something like this we can using "Batch" in testNG. What is the difference between batch and groups and when to use which one ?
Hi Hukam, can you show me some example or link where batch is used, so I can refer and check
Sir, I have created a TestNG class or XML file but out is coming not correct.
And I also use include in XML is still not working.
Hi Rahul, will need to check the setup and logs
Hello sir, my groups does not work if we have before annotation , non of the before annotation execute if we do grouping . any solution other than Always = true?
Hi, I checked online and looks like enabling the attribute alwaysRun=true is the solution for this. I will check more and update if I find anything on this
stackoverflow.com/questions/46405840/before-suite-and-beforetest-methods-are-not-called-if-groups-are-executed-in-t
Hi Raghav, Here you have all @test annotation in a single class file. My question is if there are... lets say 100 class files, then does all need to be included in class tag ...can we have groups for classes?
Hi Ankita, yes, we can create groups as we like and also do tagging
Hi Ankita, yes, we can create groups as we like and also do tagging
@raghavpal I have the same question . do we need to include multiple class names in the testng.xml?
What is the difference by adding groups in test level vs suite level...Even though you explained in words ...I am not getting that part. Please explain with some example while reply .Thanks!
Hi Daniel, sure, I will plan to add more examples
i am not getting auto suggest in testng.xml file ..please suggest raghav.
Hi Neeraj, can try to restart eclipse
@@RaghavPal I have the same issue on my Mac and tried to restart eclipse but didn't work.
:)