citrusframework / citrus

Framework for automated integration tests with focus on messaging integration
https://citrusframework.org
Apache License 2.0
457 stars 134 forks source link

Data provider for XML DSL #169

Closed arunkumarkmj closed 7 years ago

arunkumarkmj commented 7 years ago

Do we have any way by which I can add data provider and use its parameter-values within XML test case .

I tried what is mentioned in documentation by defining @CitrusParameters ,@CitrusXmlTest and TestNG data provider with empty java code for its use within XML test case (as given below) . But in XML test case i see those parameters as undefined when accessed it like ${loanAmount} . If I define these variables in XML test case then values passed from Java code is not fetched.

@Test
public class BankingAPR_Test extends AbstractTestNGCitrusTest {
    @CitrusXmlTest(name = "BankingAPR_Test")
    @CitrusParameters({"loanAmount","extraCost","interest","months","expectedAPR"})
    @Test(dataProvider = "APITestDataFile")
    public void bankingAPR_Test(String loanAmount, String extraCost, String interest , String months, String expectedAPR) {}
 .....
....
}

Please let me know if i am missing something here or if this can be fixed or supported in Citrus.

christophd commented 7 years ago

This combination is working for me:

public class BankingAPR_Test extends AbstractTestNGCitrusTest {

    @CitrusXmlTest(name = "BankingAPR_Test")
    @CitrusParameters({"loanAmount","extraCost","interest","months","expectedAPR"})
    @Test(dataProvider = "APITestDataFile")
    public void bankingAPR_Test(String loanAmount, String extraCost, String interest , String months, String expectedAPR) {}

    @DataProvider(name = "APITestDataFile")
    public Object[][] testDataFile() {
        return new Object[][] {
                new Object[] {"loanAmount", "extraCost", "interest", "months", "expectedAPR"}
        };
    }
}

<testcase name="BankingAPR_Test">
  <actions>
    <echo>
      <message>${loanAmount} ${extraCost} ${interest} ${months} ${expectedAPR}</message>
    </echo>
  </actions>
</testcase>