Questions tagged [testng-dataprovider]

TestNG @DataProvider annotation

Refers to @DataProvider, a TestNG annotation that allows combinations of parameters (test data) to be automatically injected into your test methods. It's encountered often with Selenium.

Related tags :

Reference links :

449 questions
7
votes
1 answer

How to migrate TestNG @DataProvider to JUnit Jupiter @ParameterizedTest

I have unit tests using TestNG that I try to move to JUnit Jupiter (JUnit 5), and I wonder which is the best way to do: TestNG: @DataProvider public Object[][] invalidPortNumbers() { return new Object[][] { { "--http", "" }, …
V-O
  • 123
  • 1
  • 5
7
votes
2 answers

Repeat entire test class in TestNG, with different parameters

I have this code for testing a site with selenium webdriver. There are four @Test methods, and a @DataProvider with three values. So, in total twelve tests get run. public class SomeTest { WebDriver driver; @DataProvider(name = "URLs") …
Andrio
  • 1,852
  • 2
  • 25
  • 54
6
votes
2 answers

How can I pass mock object in data provider, using Mockito TestNG?

I am trying to pass a mock object to test method through data provider. Below is my test class: @Test public class FirstTest { @InjectMocks First firstSpy; @Mock Second secondMock; @Mock Third thirdMock; @BeforeMethod public void beforeMethod()…
Caesar
  • 1,092
  • 12
  • 19
5
votes
1 answer

Parameterize @BeforeMethod method in TestNG

I have a base test class for my tests which does the initialisation work before each test. Here is the code public class BaseTestParameters { MyObj myObj; @DataProvider(name = "apiType") public static Object[][] createData() { …
5
votes
1 answer

Cannot return objects in @dataProvider PHPUnit

Is it allowed to return objects from @dataProviders to test methods? public function iOsMessages() { return [ 'update available' => [1, new UpToDateMessage(), 'pl'], ]; } /** * @test * @dataProvider iOsMessages */ public…
wujt
  • 1,278
  • 2
  • 13
  • 21
5
votes
2 answers

TestNG @Test(invocationCount = 20) to a Class with @Test(DataProvider="someList") to a Method

I have a TestNG test Suit for a JAVA Project and, In there I have a @Test(DataProvider="ListOfObjects") annotated Method. Which provides method with around 20 rows of data.( Hence the method runs 20 times.) Now, I want to run this class for 2hrs…
om Shukla
  • 61
  • 4
5
votes
2 answers

Parametrize test method in JUnit, not just whole class

I would like to make a data-driven parametrized method in JUnit. The examples that I see, parametrize the whole class. E.g. @RunWith(Parameterized.class) public class PrimeNumberCheckerTest { However, I would like to parametrize a single test…
KarolDepka
  • 8,318
  • 10
  • 45
  • 58
4
votes
1 answer

TestNG with DataProvider runs successfully but Eclipse View is not updated correctly

Problem: When I run a TestNG test using a DataProvider providing a large number of test cases, the Eclipse view for TestNG is not appropriately updated. It stops updating at a random point, and the progress bar indicates that the tests are still…
user7291698
  • 1,972
  • 2
  • 15
  • 30
4
votes
2 answers

How to use @DataProvider present in different class

How to use @DataProvider that is present in a different class? I have created a different package and I have defined data providers next to each test cases. Please share how I may to use that in a different class.
4
votes
4 answers

How to use datadriven test within @BeforeClass method in TestNG framework

Want to take urls one by one at @BeforeClass method and perform action in different @Test methods. But @dataProvider only can used along with @Test method not with @BeforeClass in TestNG constraint:- Actually, All @Test method are independent…
Rama
  • 815
  • 2
  • 17
  • 37
4
votes
1 answer

How to identify which row in a dataprovider failed?

I have a situation where there is a test that gets data from a dataprovider. This dataprovider has a lot of rows (huge dataset). I would like to understand, if there is a way to find out which data the test failed for, when there is a failure. I run…
user3325862
  • 121
  • 2
  • 7
4
votes
4 answers

how to pass > 10 parameters using TestNG DataProvider?

I need to pass more than 10 parameters to a TestNG Dataprovider, and the code look some what like this ... @Test (dataProvider = "Dataprovider1") public void testScenario1(String data1, String data2, String data3, String…
Naveen Kanak
  • 73
  • 2
  • 2
  • 6
3
votes
2 answers

Unable to control parallel execution for cucumber

I am unable to control the treads from dataproviderthreadcount. For example if we have 4 scenario and I run my script, it execute all 4 scenario's parallelly. Doesn't matter what dataproviderthreadcount value I gave in the pom for…
3
votes
1 answer

Is there a way to intercept dataprovider calls and change their return values?

I have a set of tests that take a long time to execute in total. I'd like to shorten some of my test runs by changing all data providers to return only one set of parameters. I've read through the TestNG documentation and javadoc, but there doesn't…
Erik Shreve
  • 174
  • 7
3
votes
1 answer

How to prevent dataprovider from printing the sensitive data such as login credentials on to the console?

whenever we use dataprovider in our tests , the test data which is being used will also gets print on the console, how can we disable this functionality ? Can anyone pls help me on this ? eg: @Test(dataProvider = "data-provider",…
1
2 3
29 30