I'm attempting to run some TestNG tests in parallel but don't have access to a testng.xml as IntelliJ builds it on the fly. I've tried adding parameters such as 'parallel=methods' to the run configuration but this doesn't appear to be making any difference.
How can I make TestNG run in parallel from IntelliJ without resorting to having to build my own testng.xml file?
I managed to get test methods to run in parallel without defining a custom testng.xml for each test by adding "-parallel methods -threadcount 20 -dataproviderthreadcount 20" in the "Test runner params" field of a TestNG run configuration.
It appears that you would be able to use the JDK Settings tab to specify "vm parameters", and then specify the parameters like so: -parallel methods -threadcount 2
However, IntelliJ actually creates an XML file and then uses that when running TestNG. That XML file has parallel="none" inside of it. As a result, the XML configuration 'wins' and you do not get the parallelization you are looking for.
There doesn't appear to be an easy way to adjust the contents of that default XML file, at least in terms of the parallelization options. You may just be stuck with creating XML suites yourself.
The best option for Intellij IDEA is to create additional testng.xml or you may run test from command line.
Another option is to use a 'Create TestNG XML' plugin. It instantly generates a testng.xml file so you don't have to customise one. Once installed, right click on your module name and you will see the 'Create TestNG XML' option.
You can't set this up with annotations. It must be configured in the XML. You need to set up an XML template. In eclipse it would be windows -> preferences -> testNG Template XML File.
Use an XML file that has all your parallel and usual optins and when you run as testNG it will replace only the section, while maintaining your other settings.
Related
I already changed the below items since I saw this-https://stackoverflow.com/questions/57299606/testng-by-default-disables-loading-dtd-from-unsecure-urls
Run/Debug configurations both class&method in both TESTNG and TESTNG Template vm option: -ea -Dtestng.dtd.http=true
testng.xml, and even I deleted the first line and follow the error message to put <!DECOTYPE ..... to the first line, it still failed
I still encounter this error.
Could anyone please help with this, please?
The external library was not completed.
After adding the "libs" folder under selenium-java-3.141.59 with okhttp-3.11.0.jar and okio-1.14.0.jar, it worked fine!
You don't really need to add -Dtestng.dtd.http=true if you are going to create your own testng.xml file with https for IntelliJ Run/Debug Configurations to use. You were seeing the error message because IntelliJ did not use your testng.xml file. By default IntelliJ generates a .xml file for TestNG configurations, which has a path like this C:/User/<your name>/AppData/Local/JetBrains/IntelliJIdea2020.2/temp-testng-customsuite.xml. You however cannot overwrite it because it is regenerated every time a TestNG configuration runs. IntelliJ's TestNG plugin is currently unable to dynamically generate the .xml with correct protocol, i.e. http vs https because of the concern for backward compatibility. Please see this commit for more details.
To use your own testng.xml, you need to change the Test kind of your TestNG configuration to Suite, then put/select the path of your testng.xml to be the value of Suite and apply. This answer also illustrates the above steps with images.
Last but not least, although the wording of the TestNG warning is strong, it is unlikely to be the cause of the NoClassDefFoundError in your screenshot. Maybe this is the answer for fixing that NoClassDefFoundError.
I am trying to simplify the way we run cucumbers. We have a runner for each folder and we always change the runner in a run configuration that has some VM options set.
I can right click on a feature, select "Run feature :" but it doesn't run successfully without the parameters from the run configuration (one of them runs the tests with an in memory database for example)
Is there anyway I can add a default configuration so I can run them directly?
Run -> Edit Configurations
In the left-hand panel, there is a category called defaults. You can set the defaults to cucumber there. However, note that you might have to delete your previously existing configurations to get this to work with files you've already tried. They usually appear in a faded gray.
In addition, you could also add a runner class, which can run (a subset of) your tests from a testing framework. You can provide #CucumberOptions in this runner.
How to create XSLT reports in Selenium project bases on Java and Ant.
I have already added that to my project but the result is not as per my expectation. All Testcases are passing but some are showing failed in reports
XSLT reports can be generated based on the results of your TestNG.XML file. if you are using TestNG as unit testing framework make sure to place -output directory of the TestNG should be available in home directory.
Read this (http://learn-automation.com/generate-xslt-report-in-selenium/) post you will get better Idea.
I have IntelliJ 2017.1 with TestNG and Cucumber. I can run the test from the testng.xml. However, when I try the same to run from the Cucumber feature file in IntelliJ by right mouse on the scenario and click Run, none of the settings in the testng.xml are honored. There is no way to specify testng.xml for Cucumber in Edit Configurations. Is there a workaround for this? Please help!
To run a scenario
In the Project tool window, right-click the desired feature file, or open it in the editor.
On the context menu of the desired scenario, point to Run, and then choose Run Scenario .
After running Rebuild Project successfully in IntelliJ 13.1.3 Ultimate IDE, I opened my Test NG test file.
When right-clicking on the file, I don't see any option to run the test.
How can I run an TestNG test in IntelliJ 13.1.3?
This question is similar, but it's from 2012 with an unaccepted answer.
Yes you can!
Сheck the folder that contains the test classes whether marked as Test Source Root. In another case see whether installed TestNG-J plugin.
Update:
There are 3 possibilities in the new Intellij 2017.2 to run a testNG test.
You can click on the module (project) name >>Run>>All Tests(TNG). Be careful as there are 2 'All Tests' options. The second option is the one you need. It carries a testNG logo. This way you can run all your testNG classes in parallel
The second possibility is to run a single TestNG class. Righ click the class name in the package explorer and choose 'Run Test' If your class is a testNG class, by default, the test will run as a TestNG test.
This option is my favourite as it gives me a lot of control over my tests. Install this 'Create TestNG XML' plugin. Once installed. if you right click on your module name, you will see a new option called 'Create TESTNG XML' and you will be able to directly use that option to run your TestNG tests, giving you a lot of flexibility.
It could be that a plugin that you need is disabled.
Make sure the testNg plugin is enabled.
I noticed this plugin wasn't enabled,
and as soon as I turned it on, everything started working.