Jmeter Groovy断言关键字不会导致树视图侦听器中的断言失败

时间:2017-12-28 23:17:24

标签: json groovy jmeter jsr223 jmeter-3.2

在JSR223 Assertion中使用这行代码可以在树视图监听器中使断言失败吗?

import axios from 'axios'

export function register(fields) {

    console.log('below are the fields');

    console.log(fields);


    return function action(dispatch) {

        let objArrSkills = Object.keys(fields.form_skills);

        let skillsArr = objArrSkills.map(function (value) {

            if (fields.form_skills[value] === true && fields.form_skills[value] !== undefined) {

                return value;

            }

        });

        let objArrArts = Object.keys(fields.form_arts);

        let artsArr = objArrArts.map(function (value) {

            if (fields.form_arts[value] === true && fields.form_arts[value] !== undefined) {

                return value;

            }


        });

        console.log('artsArr is...' + artsArr);

        console.log('skillsArs is...' + skillsArr);


        const request = axios({

            method: 'post',

            url: "https://jammr-backend.herokuapp.com/register",

            data: {

                firstName: fields.form_first_name,

                lastName: fields.form_last_name,

                email: fields.form_email,

                password: fields.form_password,

                skills: skillsArr,

                iWantToMake: artsArr,

                street: fields.form_address,

                city: fields.form_city,

                provinceState: fields.form_province,

                gender: fields.form_gender,

                imLookingFor: ['Acting', 'Drawing', 'Music', 'Writing', 'Programming', 'Videography']


            },

            headers: {

                'Content-Type': 'application/x-www-form-urlencoded',

                'Access-Control-Allow-Origin': '*',

                'Access-Control-Allow-Headers':   "Access-Control-Allow-Headers,Access-Control-Allow-Methods,Access-Control-Allow-Origin,Origin,X-Auth,X-Requested-With,Content-Type,Accept,content-type,application/json,x-auth,Access-Control-Request-Method,Access-Control-Request-Headers",

                'Access-Control-Allow-Methods': 'GET,PUT,POST,DELETE,PATCH,OPTIONS'

            }


        });


        return request.then(response => {

                console.log('axios call ran! Below is response....');

                console.log(response);

                dispatch({

                    type: 'REGISTER',

                    payload: {

                        myId: response.data,

                        fields: fields,

                        skills: skillsArr,

                        iWantToMake: artsArr

                    }

                })


            },
            err => {

                if (err) throw err;

            })


    }
};

在使用JMeter 3.1版之前,我可以毫无问题地执行此操作,现在它只是不起作用。我知道我可以使用这些代码行

assert 1 == 2

但如果可能的话,我希望像以前一样简单和简洁,只需一行代码

2 个答案:

答案 0 :(得分:2)

在下一个4.0版本中可以使用assert:

您可以尝试jmeter nighlty build:

我认为在3.1

中不可能这样做

答案 1 :(得分:0)

我确认可以使用上面的代码在JMeter 3.3中失败采样器(截至目前为止的最新版本)

JMeter 3.3 Groovy Response Assertion

确保:

  1. 您想要失败的采样器位于Assertion Scope
  2. 中的某个位置
  3. groovy-all.jar
  4. 中有JMeter Classpath
  5. jmeter.log 文件
  6. 中没有任何可疑条目