0

While reading one of the articles for Data Driven Testing, I came across a term 'parametrization of a test'. Could someone explain to me what is meant by parameterization here?

Lorkenpeist
  • 1,475
  • 2
  • 13
  • 26
Alpha
  • 13,320
  • 27
  • 96
  • 163
  • 3
    What is the article you are referring to? – Tim S. May 30 '13 at 18:11
  • Typically parametrization means fixing some parameters of a function or functional unit. In the context of data-driven-testing it probably means the process of defining parameters that are fixed and specifying their values. Other parameters are, in contrast, 'feeded' from existing data sources. – Stasik May 30 '13 at 18:16
  • @Tim S http://ssofttesting.blogspot.in/2009/07/data-driven-test-or-parameterization.html is the article I'm referring to. I don't know QTP still I just went through it & came across 'parameteriztion' – Alpha May 31 '13 at 03:51

1 Answers1

1

Let's see an example with TestNG. Suppose you have function SomeClass.calculate(int value). You want to check the results the function returns on different input values.

With not-parametrized tests you do something like this:

@Test
public void testCalculate1()
{
    assertEquals(SomeClass.calculate(VALUE1), RESULT1)
}

@Test
public void testCalculate2()
{
    assertEquals(SomeClass.calculate(VALUE2), RESULT2)
}

With parametrized test:

//This test method declares that its data should be supplied by the Data Provider
//named "calculateDataProvider"
@Test(dataProvider = "calculateDataProvider")
public void testCalculate(int value, int result)
{
    assertEquals(SomeClass.calculate(value), result)
}

//This method will provide data to any test method that declares that its Data Provider
//is named "calculateDataProvider"
@DataProvider(name = "calculateDataProvider")
public Object[][] createData()
{
    return new Object[][] {
       { VALUE1, RESULT1 },
       { VALUE2, RESULT2 },
    };
}

This way, TestNG engine will generate two tests from testCalculate method, providing parameters from array, returned by createData function.

For more details see documentation.

Dmitry
  • 2,943
  • 1
  • 23
  • 26