aksharagpostman / testing-sentiment2

0 stars 0 forks source link

book #100

Open aksharagpostman opened 5 years ago

aksharagpostman commented 5 years ago

I have some tests (POST {{url}}/users):

JSON body for request defined in Postman:

{
    "e-mail": "{{e-mail}}",
    "password": "{{password}}"
}

I have JSON data object set to env dataObj:

{
    "users" : {
        "userCreated":{
            "e-mail": "just@ask.me",
            "password": "Dzi0b4k!"
        },
        "invalidEmailAddress" : {
            "password" : "rightPass1@",
            "noAtChar" : {
                "e-mail": "dadadada.ta"
            },
            "noDotChar":{
                "e-mail": "dadad@adata"
            },
            "notAtLeastOneCharBeforeAt":{
                "e-mail": "@da.da"
            }
        }

    }
}

Pre-request Script section:

let dataObj = JSON.parse(pm.environment.get("dataObj"));
pm.environment.set("e-mail", dataObj.users.invalidEmailAddress.notAtLeastOneCharBeforeAt["e-mail"]);
pm.environment.set("password", dataObj.users.invalidEmailAddress.password);

For each test I set new value for "e-mail" variable from dataObj in pre-request script. It's easier to use filled JSON object than hardcoded values from data portability and management perspective. Postman documentation gets current value of "e-mail" variable at the time of generating. So ie. frontend developer will be confused seeing different test scenarios for validating e-mail address with always set the same value for e-mail property in request JSON object.

In my opinion for each endpoint before docs generation should be evaluated pre-request script section to set correct variables (could be a checkbox option). This will resolve bad request body examples in Postman docs.

aksharagpostman commented 5 years ago

I have some tests (POST {{url}}/users):

JSON body for request defined in Postman:

{
    "e-mail": "{{e-mail}}",
    "password": "{{password}}"
}

I have JSON data object set to env dataObj:

{
    "users" : {
        "userCreated":{
            "e-mail": "just@ask.me",
            "password": "Dzi0b4k!"
        },
        "invalidEmailAddress" : {
            "password" : "rightPass1@",
            "noAtChar" : {
                "e-mail": "dadadada.ta"
            },
            "noDotChar":{
                "e-mail": "dadad@adata"
            },
            "notAtLeastOneCharBeforeAt":{
                "e-mail": "@da.da"
            }
        }

    }
}

Pre-request Script section:

let dataObj = JSON.parse(pm.environment.get("dataObj"));
pm.environment.set("e-mail", dataObj.users.invalidEmailAddress.notAtLeastOneCharBeforeAt["e-mail"]);
pm.environment.set("password", dataObj.users.invalidEmailAddress.password);

For each test I set new value for "e-mail" variable from dataObj in pre-request script. It's easier to use filled JSON object than hardcoded values from data portability and management perspective. Postman documentation gets current value of "e-mail" variable at the time of generating. So ie. frontend developer will be confused seeing different test scenarios for validating e-mail address with always set the same value for e-mail property in request JSON object.

In my opinion for each endpoint before docs generation should be evaluated pre-request script section to set correct variables (could be a checkbox option). This will resolve bad request body examples in Postman docs.

aksharagpostman commented 5 years ago

I have some tests (POST {{url}}/users):

JSON body for request defined in Postman:

{
    "e-mail": "{{e-mail}}",
    "password": "{{password}}"
}

I have JSON data object set to env dataObj:

{
    "users" : {
        "userCreated":{
            "e-mail": "just@ask.me",
            "password": "Dzi0b4k!"
        },
        "invalidEmailAddress" : {
            "password" : "rightPass1@",
            "noAtChar" : {
                "e-mail": "dadadada.ta"
            },
            "noDotChar":{
                "e-mail": "dadad@adata"
            },
            "notAtLeastOneCharBeforeAt":{
                "e-mail": "@da.da"
            }
        }

    }
}

Pre-request Script section:

let dataObj = JSON.parse(pm.environment.get("dataObj"));
pm.environment.set("e-mail", dataObj.users.invalidEmailAddress.notAtLeastOneCharBeforeAt["e-mail"]);
pm.environment.set("password", dataObj.users.invalidEmailAddress.password);

For each test I set new value for "e-mail" variable from dataObj in pre-request script. It's easier to use filled JSON object than hardcoded values from data portability and management perspective. Postman documentation gets current value of "e-mail" variable at the time of generating. So ie. frontend developer will be confused seeing different test scenarios for validating e-mail address with always set the same value for e-mail property in request JSON object.

In my opinion for each endpoint before docs generation should be evaluated pre-request script section to set correct variables (could be a checkbox option). This will resolve bad request body examples in Postman docs.

aksharagpostman commented 5 years ago

I have some tests (POST {{url}}/users):

JSON body for request defined in Postman:

{
    "e-mail": "{{e-mail}}",
    "password": "{{password}}"
}

I have JSON data object set to env dataObj:

{
    "users" : {
        "userCreated":{
            "e-mail": "just@ask.me",
            "password": "Dzi0b4k!"
        },
        "invalidEmailAddress" : {
            "password" : "rightPass1@",
            "noAtChar" : {
                "e-mail": "dadadada.ta"
            },
            "noDotChar":{
                "e-mail": "dadad@adata"
            },
            "notAtLeastOneCharBeforeAt":{
                "e-mail": "@da.da"
            }
        }

    }
}

Pre-request Script section:

let dataObj = JSON.parse(pm.environment.get("dataObj"));
pm.environment.set("e-mail", dataObj.users.invalidEmailAddress.notAtLeastOneCharBeforeAt["e-mail"]);
pm.environment.set("password", dataObj.users.invalidEmailAddress.password);

For each test I set new value for "e-mail" variable from dataObj in pre-request script. It's easier to use filled JSON object than hardcoded values from data portability and management perspective. Postman documentation gets current value of "e-mail" variable at the time of generating. So ie. frontend developer will be confused seeing different test scenarios for validating e-mail address with always set the same value for e-mail property in request JSON object.

In my opinion for each endpoint before docs generation should be evaluated pre-request script section to set correct variables (could be a checkbox option). This will resolve bad request body examples in Postman docs.

aksharagpostman commented 5 years ago

I have some tests (POST {{url}}/users):

JSON body for request defined in Postman:

{
    "e-mail": "{{e-mail}}",
    "password": "{{password}}"
}

I have JSON data object set to env dataObj:

{
    "users" : {
        "userCreated":{
            "e-mail": "just@ask.me",
            "password": "Dzi0b4k!"
        },
        "invalidEmailAddress" : {
            "password" : "rightPass1@",
            "noAtChar" : {
                "e-mail": "dadadada.ta"
            },
            "noDotChar":{
                "e-mail": "dadad@adata"
            },
            "notAtLeastOneCharBeforeAt":{
                "e-mail": "@da.da"
            }
        }

    }
}

Pre-request Script section:

let dataObj = JSON.parse(pm.environment.get("dataObj"));
pm.environment.set("e-mail", dataObj.users.invalidEmailAddress.notAtLeastOneCharBeforeAt["e-mail"]);
pm.environment.set("password", dataObj.users.invalidEmailAddress.password);

For each test I set new value for "e-mail" variable from dataObj in pre-request script. It's easier to use filled JSON object than hardcoded values from data portability and management perspective. Postman documentation gets current value of "e-mail" variable at the time of generating. So ie. frontend developer will be confused seeing different test scenarios for validating e-mail address with always set the same value for e-mail property in request JSON object.

In my opinion for each endpoint before docs generation should be evaluated pre-request script section to set correct variables (could be a checkbox option). This will resolve bad request body examples in Postman docs.