Forum Discussion

MHW's avatar
MHW
New Contributor
3 years ago
Solved

Generate test without using the UI

For a specific case, I want to be able to generate the test script programmatically. Then, I want to use the command line runner to run the test.

 

Is this a common practice, and is there any documentation available for the config xml?

  • MHW 

    You say generate a test script...  That means many things to ReadyAPI/SoapUI users... Do you mean a groovy test step script that is part of a Testcase|Testsuite|Project or do you mean a whole project that contains testsuite, testcase to be executed.  It would help the community if you were a little more specific.

     

    I will just guess at what you mean however as it sounds like it could mean an entire project (not really a script as you suggest though).  I have written a testcase (group of groovy test steps) that takes xml code and assembles it into a valid ReadyAPI project.  I did not use an api to do it, only the example of an existing simple xml project.  If you examine a simple xml ReadyAPI (SoapUI) project you will see the breaks between Project parts, Suite parts, Testcase parts and Test Step parts within the xml structure.  I coded a groovy test step to write an xml file that contained the needed parts, but injected my own testcase developed xml parts (based on the model identified when examining a sample ReadyAPI xml project file).  The result was a fresh project built from the run of the testcase.

     

    The use case for this specific endeavor was to write at testcase (which was just one groovy test step) that would read a spreadsheet of requirements and build a testcase for each of the requirements.  When the business unit people would change the spreadsheet, the testcase would be run against it and a complete executable project would be built from it to replace the previous one.  It was entirely spreadsheet driven with no human maintenance of test cases, since the whole project would just be re-created as needed.  The resultant new project would be committed to its repository where CICD process would execute the contents of the project.  The business unit people would need a tiny bit of training to make sure what they were writing in the spreadsheet was "syntactically correct" since the test case code needed to be able to parse what they wrote.  The spreadsheet eventually contained hundreds of requirements and just the task of creating a test case for each of those would have taken people many hours of typing just for the name of a test case alone not even counting the creation of test steps to accomplish the test.  Given a spreadsheet in this case, the project that creates the new project was run from the command line.

     

    So... this long response may or may not answer your question, but if the question is right, this would be an answer that it is possible to do what you ask. 🙂

     

    Regards,

    Todd

6 Replies

  • richie's avatar
    richie
    Community Hero
    Hey MHW,

    Ive never heard of anyone needing to create a test without using the UI...Im intrigued....whats your use case?

    Strictly speaking, i dont know whether it would be worth the effort as your code would need to create the required testcase and teststep content within the flat project.xml file (and trying it on an unflattened composite project wouldbe even more difficult) which would be rather time intensive relative to using the UI.

    Ta,

    Rich
    • MHW's avatar
      MHW
      New Contributor

      I am a graduate looking into iPaaS solutions and how they can improve. iPaaS solutions tend to offer tools to design and deploy API integrations. Therefore, I am researching if certain software can be used to test the API programmatically. Therefore, i need to create the testing script in the iPaaS solution based on how the customer designs their API, and be able to run it in their environment

      • nmrao's avatar
        nmrao
        Champion Level 3
        Certainly one can create the project using the API's provided by Soapui or Readyapi.
        What test script does in the your use case, BTW?
  • nmrao's avatar
    nmrao
    Champion Level 3
    When you say generate test script, would you please elaborate?