Forum Discussion

nzStacy's avatar
nzStacy
Occasional Contributor
2 years ago
Solved

Project structure

Hi, I am evaluating ready API as a Postman replacement for our work and have a question around project level variables that need to be generated at some point of the API testing process.

 

I have dates for example

Past, Current and Future 

 

To get this working quickly I wrote a groovy script that returned the current date

I added this step as a test step in the flow, just before the step that needed the date in the API url, all works well

 

However I have many API calls that need the current date or other dates to test things with, so my initials thoughts were

 

1. Add a groovy script in each place - no not keen, too much work to maintain

2. Do what I did in postman and create the variables before I run any tests and save them as project variables.

 

Just really wanted an idea on how other Ready API users are doing this

 

My initial idea was to make a Test scripts test suite and put the scripts inside there that run as test steps and save the results before any of the other tests run eg

 

 

Any thoughts, feedback and ideas are all welcome, thanks

  • nzStacy's avatar
    nzStacy
    2 years ago

    Hey, thanks will have a read.

  • Your idea of a 'scripts' test case to populate your global vars is a good one.  But, you might also want t look at start up and tear down scripts.  Like the Custom Properties, these scripts can be executed once before running a test suite or test case.

3 Replies

  • ChrisAdams's avatar
    ChrisAdams
    Champion Level 3

    Hi,

     

    You can create such variables, known as Custom Properties in ReadyAPI speak.  These can be created at several layers of the ReadyAPI workspace hierarchy.

     

    Lucian wrote an excellent tech piece on how to define and access these.  See Properties Case Study 

    • nzStacy's avatar
      nzStacy
      Occasional Contributor

      Hey, thanks will have a read.

  • ChrisAdams's avatar
    ChrisAdams
    Champion Level 3

    Your idea of a 'scripts' test case to populate your global vars is a good one.  But, you might also want t look at start up and tear down scripts.  Like the Custom Properties, these scripts can be executed once before running a test suite or test case.