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 docum...
  • TNeuschwanger's avatar
    TNeuschwanger
    3 years ago

    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