testng-dataprovider

TestNG Parallel execution with selenium

本小妞迷上赌 提交于 2019-12-20 04:33:18
问题 If i need to run same one method with two different browser at the same time then how will i implement it? For example: public class AppTest2{ @parameters("browser") @Test(dataProvider="loginData") public void login(String userName , String password, String param){ if(param.equals("firefox"){ //do something } if(param.equals("chrome"){ //do something else } } } in my testng.xml file contains: <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <suite name ="My sutie" parallel =

How to override the index.html report in testNG

感情迁移 提交于 2019-12-20 03:14:46
问题 I have a scenario where I need to add some custom messages into index.html testNG report. Is there any way to do that? I just created a custom annotation which I want to publish into index.html testNG report like DataProvider did. I have been tried the below code so far. The below class will create annotation: @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.METHOD }) public @interface Greet { /** * @return - The name of the person to greet. */ String name() default ""; } I just

How Dataprovider publish the test data into HTML report

孤街醉人 提交于 2019-12-17 17:12:37
问题 I just googled but didn't get any idea about that how dataprovider publish the test data into default TestNG report. If anybody expert about the internal logic of dataprovider please let me know. It would be appreciate if there is any document to understand this better. I just created a custom annotation which I want to publish into default testNG HTML report like DataProvider did. I have been tried the below code so far. The below class will create annotation: @Retention(RetentionPolicy

TestNG “getCurrentXmlTest()).getAllParameters()” API using very old testng-5.4-jdk15.jar TestNG library

时间秒杀一切 提交于 2019-12-12 03:28:02
问题 For some reason I have to use old TestNG library which doesn't have "getCurrentXmlTest()).getAllParameters()" API How should I get all TestXML parameter using testng-5.4-jdk15.jar For latest TestNG version, this is how we get all params but how can I simulate such a code using testng-5.4-jdk15.jar @DataProvider(name = "DataFile") public Object[][] testdata(ITestContext context) { Map<String, String> parameters = (((ITestContext)context).getCurrentXmlTest()) .getAllParameters(); return new

Testng - Is it possible to pass have parameters of a Dataprovider method?

廉价感情. 提交于 2019-12-11 18:29:47
问题 DataProvider(name = "sizerDefaults") public Object[][] getSizerDefaults() { } @Test(dataProvider = "sizerDefaults") public void sizerDefaults(String... args) { } Above is my DataProvider and the methods which uses a DataProvider. Requirement is, it possible to have parameters to a DataProvider? That is, I want to use the same DataProvider for several methods, where a String value changes every time for each method, which I should be able to pass in the @Test methods wherever I am using my

How to delete data only after all tests, based on inputs from data provider, are run?

我怕爱的太早我们不能终老 提交于 2019-12-11 16:56:26
问题 I've a test with different inputs, hence used @DataProvider but before inputs, from Object[][] , passed to a test, I want to create some data which is common to test with all different inputs @DataProvider(name = "test") public Object[][] createData() { //create some data which is common for both john and bob return new Object[][] { { "john" }, { "bob" } }; } @Test(dataProvider = "test") public void userOp(String name) { //Perform some operations with user mention in `name`. For now let's

Override TestNG Test name when using a provider and omit parameters

匆匆过客 提交于 2019-12-11 04:31:22
问题 Have the following Sample code ... when running tests (and in reports), I would like the Test Names to be set to the description field provided by the provider (really it's any String). ... however, even when extending from ITest, it seems like all the provider parameters get appended to the TestName, what I want is the description only. So actual test name should be "TestName1" instead of "TestName2[1](TestName2, 2, 2, 4)" .. which is what is showing up in XML reports, and test.aftertest

How to pass parameter to data provider in testng from csv file

一笑奈何 提交于 2019-12-08 11:15:32
Am reading data from csv file , i have test for which this data will be the input . i want it to run as tescase for every set of value. for that am using data provider The problem is , it is taking only the last set row of data , please help me in debugging the code For eg : if my csv has following data name1 id1 text1 name2 id2 text2 name3 id3 text3 it taking only last row name3 id3 text3 and running the test only once not three times. @DataProvider(name = "test") public Object[][] provider( ) throws InterruptedException { Object[][] returnObject ; String[] checkpoint = ReadfromCSV(); count =

How to pass parameter to data provider in testng from csv file

喜你入骨 提交于 2019-12-08 04:11:27
问题 Am reading data from csv file , i have test for which this data will be the input . i want it to run as tescase for every set of value. for that am using data provider The problem is , it is taking only the last set row of data , please help me in debugging the code For eg : if my csv has following data name1 id1 text1 name2 id2 text2 name3 id3 text3 it taking only last row name3 id3 text3 and running the test only once not three times. @DataProvider(name = "test") public Object[][] provider(

How to get a variable value from a test method with TestNG Listeners

大兔子大兔子 提交于 2019-12-06 06:19:19
I'm using TestNG to run automation tests. I also implemented TestNG Listener to save the test results in a certain format. For some specific scenario I need to do the following: When a test runs, a value is assigned to a variable (local method variable). I need to pass the value of the variable to the TestNG Listener class I implemented. There are various methods (ontestStart, onTestFinish, onTestSuccess/Failure/Skipped), but I cannot figure out how to get the variable at run time. And I didn't find it in TestNG documentation. Can anyone please help? Or share his/her experience with a similar