• 一般是:操作->预期结果,断言应该是在每一步操作之后。
    对于场景准备类的操作可以仅做一些简单断言,比如 api 请求仅判断状态码,和一些关键业务数据

  • web 自动化想法 at January 09, 2024

    同意你的思路,按照业务行为封装方法,通过传入不同的数据完成不同的操作。怎么合理的封装行为也不是简单的事情

  • 测试点 1、2、3 是互斥的还是依赖的?如果是互斥的就不能放在一条 case 当中。如果是依赖的也有必要对大 case 进行拆分分层,当然放一起也是可以的。

  • 帖子没有写的很详细,有什么疑问,欢迎交流

  • 模板语`${vars}`

  • active choice 文档中有提到两个变量jenkinsProjectjenkinsBuild,大家一起看下怎么在 script 脚本中使用?我现在的需求是希望可以取到 jenkins 管理的 credentials 帐号密码,当前还没有找到方法。

    • jenkinsProject -> The Jenkins Project object
    • jenkinsBuild -> The Jenkins Build object


    附上我找到的一些使用方法

     properties([
                    parameters([
                            [$class: 'ChoiceParameter',
                             choiceType: 'PT_SINGLE_SELECT',
                             description: 'Select the Env Name from the Dropdown List',
                             filterLength: 1,
                             filterable: false,
                             name: 'Env',
                             randomName: 'choice-parameter-5631314439613978',
                             script: [
                                     $class: 'GroovyScript',
                                     fallbackScript: [
                                             classpath: [],
                                             sandbox: false,
                                             script:
                                                     'return[\'Could not get Env\']'
                                     ],
                                     script: [
                                             classpath: [],
                                             sandbox: false,
                                             script:
                                                     'return["Dev","QA","Stage","Prod"]'
                                     ]
                             ]
                            ],
                            [$class              : 'DynamicReferenceParameter',
                             choiceType          : 'ET_FORMATTED_HTML',
                             omitValueField      : true,
                             description         : 'Please provide a Elastic alias label',
                             name                : 'PC_CPU',
                             randomName          : 'choice-parameter-5631314456178624',
                             referencedParameters: 'NeedUpgradePC',
                             script              : [
                                     $class        : 'GroovyScript',
                                     fallbackScript: [
                                             classpath: [],
                                             sandbox  : true,
                                             script   :
                                                     'return[\'nothing.....\']'
                                     ],
                                     script        : [
                                             classpath: [],
                                             sandbox  : true,
                                             script   :
                                                     """
                                            inputBox="<input name='value' type='text' value='Intel Core i5'>"
                                    """
                                     ]
                             ]
                            ],
                            [$class: 'CascadeChoiceParameter',
                             choiceType: 'PT_CHECKBOX',
                             description: 'Select Servers',
                             filterLength: 1,
                             filterable: true,
                             name: 'Server',
                             randomName: 'choice-parameter-5631314456178619',
                             referencedParameters: 'Env',
                             script: [
                                     $class: 'GroovyScript',
                                     fallbackScript: [
                                             classpath: [],
                                             sandbox: false,
                                             script:
                                                     'return[\'Could not get Environment from Env Param\']'
                                     ],
                                     script: [
                                             classpath: [],
                                             sandbox: false,
                                             script:
                                                     ''' if (Env.equals("Dev")){
                                return["devaaa001","devaaa002","devbbb001","devbbb002","devccc001","devccc002"]
                            }
                            else if(Env.equals("QA")){
                                return["qaaaa001","qabbb002","qaccc003"]
                            }
                            else if(Env.equals("Stage")){
                                return["staaa001","stbbb002","stccc003"]
                            }
                            else if(Env.equals("Prod")){
                                return["praaa001","prbbb002","prccc003"]
                            }
                        '''
                                     ]
                             ]
                            ]
                    ])
    
    //parameters([
    //        choice(name: "NeedUpgradePC", choices: ['yes', 'no'], description: "Do you need upgrade your PC"),
    //        [$class              : 'DynamicReferenceParameter',
    //         choiceType          : 'ET_FORMATTED_HIDDEN_HTML',
    //         omitValueField      : true,
    //         description         : 'Please provide a Elastic alias label',
    //         name                : 'PC_RAM',
    //         randomName          : 'choice-parameter-5631314456178624',
    //         referencedParameters: 'NeedUpgradePC',
    //         script              : [
    //                 $class        : 'GroovyScript',
    //                 fallbackScript: [
    //                         classpath: [],
    //                         sandbox  : true,
    //                         script   :
    //                                 'return[\'nothing.....\']'
    //                 ],
    //                 script        : [
    //                         classpath: [],
    //                         sandbox  : true,
    //                         script   :
    //                                 """
    //                                    if(NeedUpgradePC.equals('yes')) {
    //                                        inputBox="<input name='value' type='text' value='Kingston 8GB'>"
    //                                    } else {
    //                                        inputBox="<input name='value' type='text' value='Kingston 8GB' disabled>"
    //                                    }
    //                                """
    //                 ]
    //         ]
    //        ],
    //        [$class              : 'DynamicReferenceParameter',
    //         choiceType          : 'ET_FORMATTED_HTML',
    //         omitValueField      : true,
    //         description         : 'Please provide a Elastic alias label',
    //         name                : 'PC_CPU',
    //         randomName          : 'choice-parameter-5631314456178624',
    //         referencedParameters: 'NeedUpgradePC',
    //         script              : [
    //                 $class        : 'GroovyScript',
    //                 fallbackScript: [
    //                         classpath: [],
    //                         sandbox  : true,
    //                         script   :
    //                                 'return[\'nothing.....\']'
    //                 ],
    //                 script        : [
    //                         classpath: [],
    //                         sandbox  : true,
    //                         script   :
    //                                 """
    //                                    if(NeedUpgradePC.equals('yes')) {
    //                                        inputBox="<input name='value' type='text' value='Intel Core i5'>"
    //                                    } else {
    //                                        inputBox="<input name='value' type='text' value='Intel Core i5' disabled>"
    //                                    }
    //                                """
    //                 ]
    //         ]
    //        ]
    //
    //])
            ])
    
  • 赞!目前已经开源了吗

  • 调用入口是:

    def call(){
    }
    
  • w3c 的 pipline 是 google 翻译的吧。看了下确实惨不忍睹