When I am running the cucumber test from testng.xml, scenarios are not executed in parallel. Scenarios are executed one after another. I am using the threads and parallel configuration in testng.xml file and using the surefire plugin for running the features.
In the Testrunner I have mentioned the website folder where I have got multiple feature file.
So when I run the test using Maven, it always executes the feature files one after another and not in parallel. What's the best way to achieve that?
Please check below configuration:
**Version of testng:**
<org.testng.testng.version>6.14.2</org.testng.testng.version>
<io.cucumber.cucumber-testng.version>2.4.0</io.cucumber.cucumber-testng.version>
**Surefire Plugin configuration from pom.xml:**
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version></version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>Testng.xml</suiteXmlFile>
</suiteXmlFiles>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
**Testng.xml file:**
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Local" parallel="tests" thread-count="5" verbose="2">
<listeners>
<listener class-name="driver.LocalWebDriverListener" />
<listener class-name="reports.ExecutionListeners" />
</listeners>
<test name="Test in Chrome">
<parameter name="browserName" value="chrome" />
<classes>
<class name="testRunner.Windows7Chrome60" />
</classes>
</test>
</suite>
**TestRunner file in which Website is the folder where I have got multiple features:**
#CucumberOptions(
strict = true,
monochrome = true,
features = {"src/main/java/features/Website"},
dryRun = false,
glue = {"driver", "stepDefination", "testRunner" },
tags = {},
plugin = { "pretty", "json:target/RawJsonResult/Windows7Chrome60.json"}
)
public class Windows7Chrome60 extends AbstractTestNGCucumberTests{
}
I agrre with #Marit that Cucumber does not support parallel execution. You might need to use an additional plugin. You can use gherkin with qaf or qaf-bdd which supports scenario level parallel execution and all features of TestNG.
Related
hope someone help me with this question, thanks !
I have this in testng.xml
<suite name="Test Project" verbose="1" thread-count="1" configfailurepolicy="continue">
<listeners>
<listener class-name="com.tests.TestListener"/>
</listeners>
<test name="Test1">
<classes>
<class name="com.tests.test1.LoginTest1"></class>
</classes>
</test>
<test name="Test2">
<classes>
<class name="com.tests.test2.LoginTest2"></class>
</classes>
</test>
</suite>
How can I run only the 'Test2'?
I tried mvn test -Dtest=Test2 but it was not working, run both tests
As explained in "maven command to run specific test class got org.testng.TestNGException"
You are mixing the two modes of execution. TestNG lets you run tests in two modes:
Via a TestNG suite xml file
Individual test classes by specifying the fully qualified class names of them.
In your case, you would need to use the class name of your Test2:
mvn test -Dtest=com.tests.test2.LoginTest2
I am running a TestNG.xml
I have created a maven project for my automation selenium script and added all the required dependencies to pom.xml. If I run the suite defined in the Testng.xml file using TestNG.run() command TestNG test result console is blank.
And please do share if there is any other way to run the testNG.xml from main() method so that I can get each test case status in testNG console
Please refer the code that I have used
TestNG testng = new TestNG();
List<String> suites = Lists.newArrayList();
suites.add(currdir+"/tempTestNG.xml");//path of xml..
testng.setTestSuites(suites);
testng.run();
Please refer the testNG.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
<parameter name="ExecutionType" value="Regression"/>
<listeners>
<listener class-name="config.TestListener"/>
</listeners>
<test name="Test">
<classes>
<class name="testsuits.VerificationOfWiki">
<methods>
<include name="VerifyMainpagetextonWiki"/>
<include name="VerifyRandomArticletextonWiki"/>
</methods>
</class>
</classes>
</test>
</suite>
When I try to run a single TestNG test class from the command line using the command
mvn test -Dtest=NBC1
where NBC1 is the name of my test class, I get an error message saying "Failed to execute goal... No tests wre executed!
I am running this using Java. My current configuration is that I have one master testng.xml suite file in my project root. I have this listed in my POM file as an XmlSuiteFile. This testng.xml file contains other suite files which contain the actual test classes. I have tried moving these out and not nesting my suite files, but it still does not work. Each test class contains only 1 test method.
Here is where I specify my top-level suite file
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
And this is what my suite file looks like
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name = "Test Suite">
<listeners>
<listener class-name="com.project.selenium.utilities.AnnotationTransformer" />
</listeners>
<suite-files>
<suite-file path="src/main/java/com/project/selenium/testsuites/foo1/FullSuite.xml" />
<suite-file path="src/main/java/com/project/selenium/testsuites/foo2/FullSuite.xml" />
</suite-files>
</suite>
This is what one of the FullSuite.xml files looks like. I've left off some suite-files for simplicity's sake
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="AssureTrak Full Suite">
<suite-files>
<suite-file path="src/main/java/com/project/selenium/testsuites/foo1/Cleanup.xml" />
<suite-file path="src/main/java/com/project/selenium/testsuites/foo1/DataSetup.xml" />
</suite-files>
</suite>
And, finally, this is a lowest level suite file looks like
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name = "DataSetup">
<test name = "DataSetup">
<classes>
<class name="com.project.selenium.testcases.foo1.datasetup.nbc.NBC1" />
<class name = "com.project.selenium.testcases.foo1.datasetup.nbc.NBC2" />
<class name = "com.project.selenium.testcases.foo1.datasetup.nbc.NBC3" />
<class name = "com.project.selenium.testcases.foo1.datasetup.nbc.NBC4" />
<class name = "com.project.selenium.testcases.foo1.datasetup.nbc.NBC5" />
</classes>
</test>
</suite>
Try upgrading to the latest version of TestNG as you might be suffering from a form of a bug
Try providing fully qualified class name like
mvn -Dtest=com.project.selenium.testcases.foo1.datasetup.nbc.NBC1 test
You can always come up with a testng.xml file to kick off the desired class like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="TestNG Debug Single Class">
<test name="testng">
<classes>
<class name="com.project.selenium.testcases.foo1.datasetup.nbc.NBC1"/>
</classes>
</test>
</suite>
however if points 1 and 2 will not help it looks like a bug so you could report it
Check out example TestNG integration instruction for more information
In my current build.gradle, i am using below target to run a specific group through command line
test {
jvmArgs "-DisParallel=true"
useTestNG(){
suites testngxml
includeGroups System.properties['groups']
}
}
Now i want to pass multiple groups with comma separated gradlew clean test -Dgroups='group1,group2'
any help please
Why not manage this at the TestNG Suite xml file instead of trying to manage this at the Gradle build file level ?
You can make use of a BeanShell within your TestNG suite xml file, that has the ability to read the group name as a JVM argument and then parse it and run tests accordingly ?
Below is an example which accepts a group name as a JVM argument and then dynamically lets tests run if and only if they belong to the group name that was passed. You can enhance this by adding your split logic and then leveraging the same containsKey() logic.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="false">
<test name="Test">
<method-selectors>
<method-selector>
<script language="beanshell">
<![CDATA[whatGroup = System.getProperty("groups");
groups.containsKey(whatGroup);
]]>
</script>
</method-selector>
</method-selectors>
<classes>
<class name="organized.chaos.GroupsPlayGround" />
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
For more information you can refer to the following :
TestNG Documentation
My Blog post
I'm looking for documentation for .runsettings files as used with vstest. Is there an xsd?
I can't seem to find much except for a few example files in the msdn documentation.
Runsettings (VS2012) are similar to testsettings (VS2010) where testsettings is specific to tests written for MSTest. VS2012 supports settings for different adapters. As such, the schema isn't a closed system so an XSD would not be comprehensive.
This MSDN article lists some high level details (https://msdn.microsoft.com/en-us/library/jj635153.aspx) for the elements in the runsettings file.
Here's a snippet from that article.
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- Configurations that affect the Test Framework -->
<RunConfiguration>
<MaxCpuCount>1</MaxCpuCount>
<!-- Path relative to solution directory -->
<ResultsDirectory>.\TestResults</ResultsDirectory>
<!-- [x86] | x64
- You can also change it from menu Test, Test Settings, Default
Processor Architecture -->
<TargetPlatform>x86</TargetPlatform>
<!-- Framework35 | [Framework40] | Framework45 -->
<TargetFrameworkVersion>Framework40</TargetFrameworkVersion>
<!-- Path to Test Adapters -->
<TestAdaptersPaths>%SystemDrive%\Temp\foo;%SystemDrive%\Temp\bar</TestAdaptersPaths>
</RunConfiguration>
<!-- Configurations for data collectors -->
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>
<ModulePaths>
<Exclude>
<ModulePath>.*CPPUnitTestFramework.*</ModulePath>
</Exclude>
</ModulePaths>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
<!-- Parameters used by tests at runtime -->
<TestRunParameters>
<Parameter name="webAppUrl" value="http://localhost" />
<Parameter name="webAppUserName" value="Admin" />
<Parameter name="webAppPassword" value="Password" />
</TestRunParameters>
<!-- Adapter Specific sections -->
<!-- MSTest adapter -->
<MSTest>
<MapInconclusiveToFailed>True</MapInconclusiveToFailed>
<CaptureTraceOutput>false</CaptureTraceOutput>
<DeleteDeploymentDirectoryAfterTestRunIsComplete>False</DeleteDeploymentDirectoryAfterTestRunIsComplete>
<DeploymentEnabled>False</DeploymentEnabled>
<AssemblyResolution>
<Directory Path>"D:\myfolder\bin\" includeSubDirectories="false"/>
</AssemblyResolution>
</MSTest>
</RunSettings>
I found further information on runsettings (specific to code coverage) here:
http://msdn.microsoft.com/en-us/library/jj159530%28v=vs.110%29.aspx