testng-dataprovider

TestNG DataProvider returning object and RetryAnalyzer does not recognize retry

♀尐吖头ヾ 提交于 2021-01-27 17:53:06
问题 I've looked everywhere I know and I can't seem to find an answer for this one. If I pass a "complex" object from DataProvider to test method the Invoker seems to get a new instance of RetryAnalyzer with each iteration. IRL, my data provider makes a DB query and passes objects to the test method. I assumed originally the DB access was causing issues, but have since narrowed it down to what I think is simplest example. Please see below. If I set a breakpoint in RetryAnalyzer I can see that

Allure TestNG: Custom test method names while using @DataProvider

℡╲_俬逩灬. 提交于 2021-01-01 08:18:07
问题 I am using allure-testng(2.12.1) adapter in my java testng tests. I have tests that are using @DataProvider. My test implements ITest to change the test method instance name during runtime. When I run the tests, I see the different test method names, but in allure-report it shows same test method for each test run. How can I configure allure report to show similar to IDE? @Listeners({AllureTestNg.class, EmailableReporter.class}) public class AllureTests implements ITest { private ThreadLocal

Running a testng class file with many dependent test methods multiple times sequentially

旧巷老猫 提交于 2020-01-16 08:41:21
问题 I have a test class with multiple methods written in RestAssured and TestNG. And I want to execute these methods sequentially in a loop. How can we do that? The requirement is to fill up a train. I have an API which gives me the number of seats available on a train. Knowing that number, I want to run a loop such that it executes a few test methods like do a journey search, create a booking, make the payment and confirm the booking sequentially every time. So lets say if we have 50 seats

TestNG - Dataprovider at Class level test annocation

烈酒焚心 提交于 2020-01-07 06:31:48
问题 I will try and explain my scenario here so that it's clear what I want. I have a set of methods within a Class which performs a few tests, they are all related to each other and have to be run in a sequence, so they have DependsOnMethod in their @Test annotation. I am also using a DataProvider which returns 7 values per test (n rows & 7 columns). Now when I put this data provider at the method level, it reads all the rows and executes Method 1 with every set of data available, then moves onto

Datadriven not working using Testng data provider

◇◆丶佛笑我妖孽 提交于 2020-01-06 05:34:17
问题 I am trying to read data from excel using apache poi with testng data provider but testng is skipping my test method. Below is the error am getting SKIPPED: VerifyLoanDetails java.lang.RuntimeException: java.lang.NullPointerException Caused by: java.lang.NullPointerException at com.seleniumhybrid.utils.ExcelUtil.getTestdata(ExcelUtil.java:62) at com.seleniumdata.zmartano.LoanDetails.getdata(LoanDetails.java:50) Below is my class to read data from excel public class ExcelUtil{ static Workbook

How to get total amount of tests (incl. taking data providers into account) at TestNG start?

允我心安 提交于 2019-12-25 04:38:12
问题 Can anyone tell me how to get (expected) count of all tests / method executions at TestNG (suite) start? You can easily get the amount of all test methods, but this doesn't count each test method times the amount of the data provider size (each method will be counted once, even if one method is executed 100 times via a data provider). Unless there is an obvious solution to this, like a simple API call, the key seems to be to figure out the data provider method from the data provider name

How to get data provider method from TestNG data provider name?

流过昼夜 提交于 2019-12-25 03:00:26
问题 Does anyone know how TestNG figures out what the data provider method is based on the data provider name specified for a test method? I found this solution: https://gist.github.com/ae6rt/3805639 However, it doesn't take into account that the data provider could be: defined in a completely different class, or defined in a parent class, and the method can be either static, or not static. I tried to hack something together on my own, but then I figured that I can't possibly be the first person

How to read a numeric value (i.e. double value) from excel sheet using apache poi

旧巷老猫 提交于 2019-12-24 18:35:43
问题 When I am passing numeric values into excel sheet, it is taking as double so that there was DataProvider Mismatch exception. How to handle this exception and how to pass only numeric values instead of double values? Below is my code: @DataProvider(name = "testdata") public Object[][] TestDataFeed() throws Exception { FileInputStream fis = new FileInputStream("C:\\Users\\vidhya.r\\Desktop\\Testdata.xlsx"); XSSFWorkbook wb = new XSSFWorkbook(fis); XSSFSheet sh1 = wb.getSheetAt(2); int numrow =

TestNG Parallel Tests using Data Provider

ぃ、小莉子 提交于 2019-12-24 08:09:16
问题 I would like to simulate Google Search with various search parameters in parallel using Selenium and TestNG. Below are my test class and testng.xml. I have tested my test clases using below annotations @Test(dataProvider="googlesearchDataProvider",threadPoolSize=3,singleThreaded=false) or testng.xml. Both the cases tests ran in single browser single threaded. Could you please let me know what is wrong and what needs to be done. I want at a time there will be 3 independent browser instances

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

只谈情不闲聊 提交于 2019-12-22 11:33:57
问题 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