When we use dataProvider and when we use external data sources (XML, Excel, JSON), and why for data-driven testing in Automation?

61 Views Asked by At

I am new to Automation Testing while using data-driven testing we need to send data from external sources like XML, JSON, or excel files or sometimes from dataProvider in a java file. But when should go with dataProvider and when with external data sources and why, please correct me if I am wrong.

1

There are 1 best solutions below

0
JeffC On

I only use data-driven methods when I'm using multiple data sets on one script. Here's a simple JUnit example

@ParameterizedTest
@ValueSource(strings = {"", "  "})
void isBlank_ShouldReturnTrueForNullOrBlankStrings(String input) {
    assertTrue(Strings.isBlank(input));
}

If I'm only running a script once with a single set of data, e.g. username and password, I store those in a db and pull them into the test directly.