Setting up an API Test Framework



  • I'm testing an API and I'm looking to define my payload using classes so that my program can then deserialize/serialize into any format (namely XML in my case). Below is an example of the payload:

    <Order>
           <BillingAddress>
             <AddressLine1></AddressLine1>
             <AddressLine2></AddressLine2>
             <City></City>
           </BillingAddress>
           <Items>
             <Item IsKit="false">
             <CountryVATRate></CountryVATRate>
             <Group></Group>
             <Reference></Reference>
           </Item>
           <Item IsKit="false">
            <CountryVATRate>0.25</CountryVATRate>
            <Group>5360693120</Group>
            <Reference>5360693120</Reference>
           </Item>
         </Items>
         <OrderAmount>35</OrderAmount>
         <TimeStamp>2017-03-30 00:00:00.102</TimeStamp>
        </Order>
    

    So my thinking is that I would have an overall Order class which looks something like the below

    public class Order()
        {
          BillingAddress bAddr; //another class
          List Items;
          double OrderAmount;
          DateTime TimeStamp;
         }
    

    What I am trying to work out is the best way of setting up my framework so that in the example of the BillingAddress class I can set up a series of properties e.g. AddressLine1/AddressLine1 etc which can then be called when I run the test

    Any advice on how to structure the test framework would be most appreciated



  • I’m not sure how it works in C# but you may use the optional arguments. Also I would recommend to create a models of your payloads. - models -> - xml - xml then pass this file as your payload. In your case it’s XML and for example interface.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2