Using ChatGPT to improve testing work efficiency - a new tool for test engineers (1) | JD Cloud Technology Team

1 Introduction

With the popularity of ChatGPT, various industries have begun to try to use ChatGPT to improve work efficiency. Among them, test engineers have also begun to explore how to apply ChatGPT to strengthen testing work. In this article, we will discuss the application of ChatGPT in testing work from the perspective of a test engineer. Through ChatGPT, test engineers can quickly conduct human-computer dialogue, thereby accelerating the execution of test tasks. Whether it is requirements analysis, test case writing, defect reporting or automated test script generation, ChatGPT can provide accurate suggestions and guidance. At the same time, using ChatGPT can also reduce the workload of test engineers, allowing them to focus on more challenging testing tasks.

Not only that, ChatGPT can also help test engineers solve problems during the execution of tests. When encountering problems with test environment configuration, test data generation, test case design, etc., test engineers can get real-time help and guidance through conversations with ChatGPT. To sum up, ChatGPT is not only a tool to improve work efficiency, but also a reliable intelligent assistant for test engineers. By making full use of the capabilities of ChatGPT, test engineers can complete tasks more efficiently and accurately during testing and protect software quality.

2. Functional test case generation

For test engineers, requirement analysis and writing test cases account for a large part of the entire testing process. If you can use chatGPT to conduct demand analysis and output test cases with better quality, it will greatly improve the work efficiency of test engineers. However, after testing, sometimes inputting requirements into chatGPT does not produce satisfactory results. But for system or form-level requirements, the results given by chatGPT are basically satisfactory. It is even possible to directly generate test test cases from given front-end functional code.

For example: For those who don’t understand multi-tenant systems at all, you can let chatGPT give you some test points and directions. Note: The result screenshot is too long and only part of it is shown.

Example: Given the input parameters, parameter value ranges and constraints for each field of the specified form, chatGPT is required to generate various use case combinations. Note: The result screenshot is too long and only part of it is shown.

Example: Generate functional test cases directly through part of the front-end code (pay attention to code security protection). Note: The result screenshot is too long and only part of it is shown.

示例代码:<div class="valign_wrap">
        <!-- +.withqrc 切换 -->
        <div class="login_pop">
            <div class="login_pop_inner login_withpc" style="height: auto;padding-top:40px;padding-bottom: 20px">
                    <div id="checkCodeDiv" style="display: none;font-size: 18px" class="login_form_row account">
                        <div style="width: 100%;text-align: center;">登录账号:<span style="font-weight:bold">wywangyanjie</span> </div>
                        <br>
                        <div>请在您的<span style="color: red;font-weight:bold">京Me</span>上确认,登录验证码<br><span style="text-align: center;display:-moz-inline-box;display:inline-block;width:90px;color: red;font-weight:bold;font-size: 22px;"></span>,请在<span style="color: red;font-weight:bold">分钟内</span>完成操作!</div>
                        <input type="hidden" id="checkCode" name="checkCode?if_exists" value="">
                        <br>
                    </div>
                    <div id="reSubmitDiv" style="display: none;font-size: 18px" class="login_form_row account">
                        <div style="width: 100%;text-align: center;">您的账号<span style="font-weight:bold">wywangyanjie</span>,本次登录已超时,请重新登录! </div>
                        <br>
                        <div class="login_form_row formsubmit"><input class="formsubmit_btn" type="button" onclick="refreshPage()" value="重新登录"></div>

                    </div>
                    <div id="errorDiv" style="display: none;font-size: 18px" class="login_form_row account">
                        <div style="width: 100%;text-align: center;">您的账号<span style="font-weight:bold">wywangyanjie</span>,本次登录存在异常情况,请重新登录! </div>
                        <br>
                        <div class="login_form_row formsubmit"><input class="formsubmit_btn" type="button" onclick="refreshPage()" value="重新登录"></div>
                    </div>
                    <div id="loginDiv" style="display: none;font-size: 18px" class="login_form_row account">
                        <div style="width: 100%;text-align: center;">您的账号<span style="font-weight:bold">wywangyanjie</span>,已被拒绝登录,请重新登录! </div>
                        <br>
                        <div class="login_form_row formsubmit"><input class="formsubmit_btn" type="button" onclick="refreshPage()" value="重新登录"></div>
                    </div>

                </form>
                <a class="login_style to_qrcode" href="javascript:;" tologintype="2" title="切换到扫码登录"></a>
            </div>
                <div class="login_withqrc_result">
                    <div class="login_withqrc_doge"></div>
                    <div class="login_withqrc_succ">扫描成功!</div>
                    <div class="login_withqrc_tip">请在手机上确认是否登录</div>
                </div>
                <a class="login_style to_password" href="javascript:;" tologintype="1" title="切换到密码登录"></a>
            </div>
            <div id="otherDiv" class="login_pop_inner" style="height: auto;padding-top:20px;padding-bottom: 20px">
                <div style="text-align: center">
                    <div class="login-way" id="passwordDiv" title="密码登录" style="width: 22%;">
                        <div>密码登录</div>
                    </div>
                    <div class="login-way" id="qrcodeDiv" title="扫码登录" style="width: 22%;">
                        <div>扫码登录</div>
                    </div>
                </div>
                <div class="login_form_row formsubmit"><input class="formsubmit_btn" type="button" id="formsubmitButton" value="登  录"></div>
                <div class="login_form_row findback" id="forgetPwdDiv"><a href="/sso/findpwd/index">忘记密码?</a></div>
                <div class="login_form_row warntip hide" style="margin-top: 10px; display: block;"><i class="warntip_icon"></i><span class="warntip_text">用户名或密码错误,请重试!</span>
                </div>
                <div class="login-language">
                    <span class="lan-title">语言选择</span>
                    <div class="lan-part">
                        <select class="lanselect" id="lanSelect" onchange="selectLan()">
                            <option value="zh_CN">中文</option>
                            <option value="en_US">English</option>
                        </select>
                    </div>
                </div>

            </div>
        </div>
    </div>
    

3. Code-assisted generation

The code assistance function is a basic function. For some methods or functions, you can automatically generate code by giving chatGPT instructions or requirements. Although the generated code may have some errors or not meet expectations, it can indeed give us some ideas or basic code. . Changes or optimizations can be made based on the automatically generated code, which can greatly improve the efficiency of our code writing.

4. Interface test case generation

Give chatGPT the input interface, the corresponding input parameters and input parameter constraints, and let it generate test cases. The use case scenarios given by chatGPT basically cover all, and 20 use cases are generated given four parameters (this function can be rated 10 points). In actual work, it can be streamlined and tested based on actual scenarios, but if the system requirements are relatively high, such as a banking system, it may need to be covered as fully as possible.

5. Interface automation script generation

Please refer to the article for details: Efficiency-oriented: Using ChatGPT and HttpRunner to implement agile automated testing (2)

Implementation process idea: first provide the written interface automation script example to chatGPT, and then provide the generated interface test case to chatGPT. It can automatically convert the interface automation test case into a script according to the given example. Of course, the specific assertions need to be modified according to the actual situation. Note: The result screenshot is too long and only part of it is shown.

Note: The above automation script is implemented through the Httprunner ( official website link) framework.

6. Others

In other directions, such as SQL, DockerFile, Nginx configuration, Shell scripting, etc., chatGPT can help with all aspects. I will not take screenshots one by one and give examples. This is simply too friendly for novices who have not been exposed to relevant knowledge. Although search engines can also find corresponding content, manual screening and integration may be required. With the help of chatGPT, beginner players can become intermediate players if used properly.

Generally speaking, using ChatGPT to generate code, generate use cases, generate SQL, DockerFile, Nginx configuration and Shell scripts, etc., although it can provide certain guidance and reference, it still requires manual verification and optimization to ensure that the generated content meets expectations. Although some simple things can be completed from zero to one by yourself, if you use the command to let chatGPT automatically generate and complete it, and then manually modify the verification, it will definitely be faster than implementing it from zero to one.

7. Summary

Summary: In testing work, it can assist functional testing, including demand analysis or code interpretation (pay attention to code security) to generate test cases. It can also assist in generating code, interface test cases, automated scripts and other directions. Of course, in actual use, the generated results may require multiple manual dialogue trainings due to different prompt words. But using chatGPT will definitely improve work efficiency than not using it. Of course, issues such as how to quantify and improve efficiency after implementation are still being explored, and there is still a long way to go after taking the first step.

Author: Zhang Xinglei, JD Technology

Source: JD Cloud Developer Community Please indicate the source when reprinting

The author of the open source framework NanUI switched to selling steel, and the project was suspended. The first free list in the Apple App Store is the pornographic software TypeScript. It has just become popular, why do the big guys start to abandon it? TIOBE October list: Java has the biggest decline, C# is approaching Java Rust 1.73.0 Released A man was encouraged by his AI girlfriend to assassinate the Queen of England and was sentenced to nine years in prison Qt 6.6 officially released Reuters: RISC-V technology becomes the key to the Sino-US technology war New battlefield RISC-V: Not controlled by any single company or country, Lenovo plans to launch Android PC
{{o.name}}
{{m.name}}

Guess you like

Origin my.oschina.net/u/4090830/blog/10116827