Unit Testing for Data Providers

Official Content

Data Provider objects provide data collection or data structure in an easy, and high-level declarative wayTheir output can be a Structured Data Type or a Business Component. You may want to test if your Data Provider is working properly.

Consider the following basic example.

Suppose a Transaction object calledCountry” (which has its Business Component property set to True) with the following structure:

image_2019415113958_1_png

Suppose you also have a Data Provider object which receives the name of a country as a parameter and returns a variable based on a Country Business Component with the name and the capital of it.

A Unit Test object can verify that the Data Provider is returning the information correctly. In order to do that, being in the KB Explorer you can right-click on the Data Provider and select in the contextual menu: Create Unit Test.

image_2019415114118_1_png

Then, an auto-generated skeleton of your Unit Test is created:

image_2019415114215_1_png

You need to add to the SDT the data you want to check, in this case, you want to check the Capital of each country:

image_2019415115332_1_png

After that, just define data to test in the corresponding test's Data Provider:

image_201941512015_1_png

And modify your test adding an assertion between the result of the call (GetCountryByName) against test data expected (&TestCaseData):

image_201941512429_1_png

Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.