GithubHelp home page GithubHelp logo

Comments (11)

UmeshIghe avatar UmeshIghe commented on September 4, 2024

Is this branch merged with master ?

from zerocode.

dinesh76in avatar dinesh76in commented on September 4, 2024

Not exactly. This was not a blocker and also it was argued that - the independent-ness of the test cases and the readability will be lost if allowed this way. Also one has to traverse to n fro via the IDE to know the payload structure. So it was paused.

Are you looking for load testing ? or stress testing aka performance testing?
Framework recently developed this and enables loading the same test(s) number of times, in a particular interval of time and all these are configurable in a properties file.

from zerocode.

UmeshIghe avatar UmeshIghe commented on September 4, 2024

I am doing Functional testing, I am also looking a way where we can parameterize a test using external data source like csv.
Having Json externalize can reduce the size of json, also it will avoid duplicate data, just a thought

from zerocode.

authorjapps avatar authorjapps commented on September 4, 2024

@UmeshIghe , sounds good to reuse the payload from a JSON file, that's why this ticket was for 👍. But as mentioned in the earlier comment , the traversing n independentness will be lost, that's the trade-off of this approach.

Anyways, we will include this feature in our upcoming release(a week or so - will try). 👍
Please watch n follow our latest news/releases/features etc in Twitter.
Readme section - https://github.com/authorjapps/zerocode#latest-newsreleasesfeatures

Note-
Even now you can achieve this via calling a Java(Pojo), but JSON is better in my opinion in order to copy paste as it is like postman. Let's go for JSON file way.

@macrocks @officiallysameer @dinesh76in, @nirmalchandra and all, let me know your thoughts! Can you pick this tkt?

from zerocode.

albertosipov avatar albertosipov commented on September 4, 2024

Also this makes sense, doesn't it ?

{
    "name": "update_address",
    "url": "/api/v1/addresses/AD-US-01",
    "operation": "PUT",
    "request": {
        "body": "${JSON.FILE:test_files/address_request.json}"
    },
    "assertions": {
        "status": 200,
        "body"{
            "id": "AD-US-01"
         }
    }
}

and if you make a GET call(which of course is necessary to verify the result)
then it should allow to assert from a file too ?

{
    "name": "Get the address",
    "url": "/api/v1/addresses/${$.update_address.response.id}",
    "operation": "GET",
    "request": {
    },
    "assertions": {
        "status": 200,
        "body": "${JSON.FILE:test_files/address_response.json}"
    }
}

What you think @UmeshIghe @macrocks @nirmalchandra @officiallysameer ?
Better ?

If we are allowing body JSON file, we should allow the response JSON file ?

I am leaving it open for discussion.

from zerocode.

aghorpade avatar aghorpade commented on September 4, 2024

@UmeshIghe @albertosipov .Yes it is a good feature to be pick it as an enhancement. It will help everyone to reuse json in multiple test cases.

from zerocode.

authorjapps avatar authorjapps commented on September 4, 2024

Yeah, also the following too makes sense,

Here, only the 'addresses' part of it is common(not the entire body payload) and can be read from a Json file.

{
    "name": "update_addresses",
    "url": "/api/v1/addresses/emp_001",
    "operation": "PUT",
    "request": {
        "body": {
            "updatedDate": "2018-10-10",
            "addresses": "${JSON.FILE:test_files/common_addressses.json}"
        }
    },
    "assertions": {
        "status": 200,
        "body": {
            "addresses": "${JSON.FILE:test_files/common_addressses.json}"
        }
    }
}

and the common_addressses.json can be like below,

[
    {
        "type":"corp-office",
        "city":"Texas"
    },
    {
        "type":"hr-office",
        "city":"Newark"
    }
]

Basically, resolve the JSON.FILE in request and response(ie assertion) node by deep traversing.

Also JSON.FILE sounds meaningful than JSON.PAYLOAD.FILE.
I will update the description if there are no objections from anyone.

@UmeshIghe, are you happy for these implementations?

from zerocode.

nirmalchandra avatar nirmalchandra commented on September 4, 2024

fyi - PR raised n under review, PR No- #138
Things pending-

  • Update README file
  • Add a wiki page for this feature

from zerocode.

UmeshIghe avatar UmeshIghe commented on September 4, 2024

Yeah, also the following too makes sense,

Here, only the 'addresses' part of it is common(not the entire body payload) and can be read from a Json file.

{
    "name": "update_addresses",
    "url": "/api/v1/addresses/emp_001",
    "operation": "PUT",
    "request": {
        "body": {
            "updatedDate": "2018-10-10",
            "addresses": "${JSON.FILE:test_files/common_addressses.json}"
        }
    },
    "assertions": {
        "status": 200,
        "body": {
            "addresses": "${JSON.FILE:test_files/common_addressses.json}"
        }
    }
}

and the common_addressses.json can be like below,

[
    {
        "type":"corp-office",
        "city":"Texas"
    },
    {
        "type":"hr-office",
        "city":"Newark"
    }
]

Basically, resolve the JSON.FILE in request and response(ie assertion) node by deep traversing.

Also JSON.FILE sounds meaningful than JSON.PAYLOAD.FILE.
I will update the description if there are no objections from anyone.

@UmeshIghe, are you happy for these implementations?

Yes , this is also good

from zerocode.

authorjapps avatar authorjapps commented on September 4, 2024

@UmeshIghe , this has been released now, the version is as below.

<!-- https://mvnrepository.com/artifact/org.jsmart/zerocode-rest-bdd -->
<dependency>
    <groupId>org.jsmart</groupId>
    <artifactId>zerocode-rest-bdd</artifactId>
    <version>1.2.8</version>
</dependency>

We will update the release notes and README file with examples soon.

In the mean time, you can pick the handy examples from our HelloWorld repo(as shown below) :

hello_world_passed

Here is a sample test-case with external file as JSON content.


{
    "scenarioName": "POST API - File json as response content - Reuse body",
    "steps": [
        {
            "name": "create_emp",
            "url": "/api/v1/employees",
            "operation": "POST",
            "request": {
                "body" : "${JSON.FILE:reusable_content/request/request_body.json}"
            },
            "assertions": {
                "status": 201
            }
        },
        {
            "name": "get_user_details",
            "url": "/api/v1/employees/${$.create_emp.response.body.id}",
            "operation": "GET",
            "request": {
            },
            "assertions": {
                "status": 200,
                "body" : "${JSON.FILE:reusable_content/response/response_body.json}"
            }
        }
    ]
}

Wiki page for this feature-
https://github.com/authorjapps/zerocode/wiki/External-JSON-file-as-reusable-content

from zerocode.

authorjapps avatar authorjapps commented on September 4, 2024

Hello mate @UmeshIghe, When u get chance, can you say Hello in gitter chat room please? 🙏
Gitter link: https://gitter.im/zerocode-testing/help-and-usage

Sounds like you are doing something interesting and will be nice if you publish a small write-up/article as a blog.

from zerocode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.