Test code modification method and apparatus
The use of generative AI to automate test code generation for modified applications addresses the inefficiencies of manual coding, enhancing testing efficiency and accuracy by detecting and applying necessary changes to test code.
Patent Information
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Filing Date
- 2025-02-25
- Publication Date
- 2026-03-05
AI Technical Summary
Conventional application testing automation tools require specialized knowledge and are time-consuming due to the manual coding of test code, necessitating a more accessible and efficient method for testing modified applications.
A method utilizing a generative AI to detect differences in application screen information before and after modification and automatically generate modified test code based on these differences, reducing the need for manual coding.
Facilitates easy and efficient testing of modified applications by automating the generation of test code, thereby reducing manual effort and improving accuracy through AI-driven difference detection and modification.
Smart Images

Figure 0007825088000001_ABST
Abstract
Description
[Technical Field]
[0001] The present invention relates to a method and apparatus for modifying test code. [Background technology]
[0002] Conventionally, during and after the development of an application such as a web application, testing is performed to verify whether the application operates correctly. For example, end-to-end testing (E2E testing) is performed as a front-end test to verify whether the application's screen transitions are performed correctly.
[0003] Whenever an application is modified, it must be tested, and each time an application is modified, test code is required to test the application. [Prior art documents] [Patent documents]
[0004] [Patent Document 1] Japanese Patent Application Laid-Open No. 2007-102654 Summary of the Invention [Problem to be solved by the invention]
[0005] However, it takes a lot of time to manually code the test code used to test an application. For this reason, tools to automate application testing are provided. Conventional application testing automation tools require specialized knowledge, so there is a demand for easier application testing.
[0006] Therefore, in the present invention, when an application is modified, the modified application can be easily tested. [Means for solving the problem]
[0007] A method according to one embodiment of the present invention is a method for modifying test code for an application, which comprises inputting test code for the application before modification, screen information for the application before modification, screen information for the application after modification, and a prompt instructing the AI to detect differences between the screen information for the application before modification and the screen information for the application after modification into a generation AI, causing the AI to output the differences, and inputting a prompt instructing the AI to modify the test code for the application before modification based on the differences or differences modified by a user into the differences, causing the AI to output test code for the application after modification. [Effects of the Invention]
[0008] According to the present invention, when an application is modified, the modified application can be easily tested. [Brief explanation of the drawings]
[0009] [Figure 1] 1 is a diagram showing an overall configuration according to an embodiment of the present invention; [Figure 2] FIG. 10 is a sequence diagram of test code modification according to an embodiment of the present invention. [Figure 3] 1 is a functional block diagram of a test code modifying device according to an embodiment of the present invention; [Figure 4] 1 is a hardware configuration diagram of a test code modifying device according to an embodiment of the present invention; DETAILED DESCRIPTION OF THE INVENTION
[0010] Hereinafter, an embodiment of the present invention will be described with reference to the drawings.
[0011] <Terminology> An "application" may be any application (also called application software, software, application program, or program). For example, an application may be a web application. For example, an application may be modified (also called a version upgrade or update) to add features, fix bugs, etc. "Test" is a test to verify whether an application works correctly. For example, the test is an end-to-end test (E2E test), which is a type of front-end test. For example, the test is a test of the application's screen transitions. "Test Code" is code written in a programming language used in testing to verify that an application works correctly. Test Code is not limited to a specific format. Test Code is not limited to a specific programming language or testing library. For example, the programming language for the test code is Java and the testing library is Selenide (Selenium), but these are not limitations. "Screen information" is information about each screen included in an application. For example, screen information is information about the DOM (Document Object Model) of a screen included in an application. For example, "screen information" is only information described in the body tag of the DOM (in other words, it does not include information described in tags other than the body tag). "Generative AI (Artificial Intelligence)" is an artificial intelligence system that generates text or other responses to prompts. For example, generative AI has a file reference function (the ability to reference a file pasted into the prompt). Furthermore, GPT-4o was more accurate at detecting differences between the application's screen information before and after modification than GPT-4 Turbo. Furthermore, GPT-4o was able to correctly modify the test code based on the detected differences.
[0012] <Overall structure> Figure 1 is a diagram showing the overall configuration according to one embodiment of the present invention. A test code modifying device 10 can send and receive data to and from a generation AI providing device 20 via any network (note that while Figure 1 illustrates a case where there is one test code modifying device 10, multiple test code modifying devices 10 may be connected to the generation AI providing device). Each of these will be explained below.
[0013] <<Test code correction device>> The test code modifying device 10 modifies test code for an application before modification into test code for the application after modification using a generation AI 21 of a generation AI providing device 20. The test code modifying device 10 is a personal computer, a tablet, a smartphone, or the like.
[0014] Specifically, the test code modification device 10 inputs the test code for the application before modification, the screen information of the application before modification, the screen information of the application after modification, and a prompt instructing the generation AI 21 to detect the difference between the screen information of the application before modification and the screen information of the application after modification, causes the generation AI 21 to output the difference (i.e., the difference between the screen information of the application before modification and the screen information of the application after modification), and inputs a prompt instructing the generation AI 21 to modify the test code for the application before modification based on the difference (i.e., the difference between the screen information of the application before modification and the screen information of the application after modification) or the difference modified by the user 30 (note that the difference or the difference modified by the user 30 may also be input), and causes the generation AI 21 to output the test code for the modified application.
[0015] [Test code for the application] Here, the test code for the application before modification and the test code for the application after modification will be described.
[0016] The test code for the application before modification is test code used in tests to verify whether the application before modification operates correctly. The test code for the application before modification is assumed to be generated by any method (for example, it may be test code generated by inputting prompts to generate test code into a generation AI, or it may be test code coded by a person).
[0017] The test code for the modified application is test code used in a test to verify whether the modified application operates correctly.
[0018] [Difference between application screen information before and after modification] Here, we will explain the differences between the screen information of the application before modification and the screen information of the application after modification. The differences indicate the changes, additions, and deletions between the screen information of the application before modification and the screen information of the application after modification, such as A being changed to B, C being added, D being deleted, etc.
[0019] <<Generation AI providing device>> The generated AI providing device 20 is a device (for example, a server) that provides a service that allows the use of the generated AI 21. The generated AI providing device 20 is configured from one or more computers.
[0020] <Processing method> FIG. 2 is a sequence diagram of test code modification according to an embodiment of the present invention.
[0021] In step 1 (S1), a user 30 operating the test code modifying device 10 inputs to the test code modifying device 10 a test code for the application before modification, screen information of the application before modification, screen information of the application after modification, and a prompt instructing the test code modifying device 10 to detect differences between the screen information of the application before modification and the screen information of the application after modification.
[0022] In step 2 (S2), the test code modifying device 10 transmits the test code for the application before modification, the screen information of the application before modification, the screen information of the application after modification, and a prompt to detect a difference between the screen information of the application before modification and the screen information of the application after modification, which were input in S1, to the generation AI providing device 20. The generation AI providing device 20 receives the test code for the application before modification, the screen information of the application before modification, the screen information of the application after modification, and a prompt to detect a difference between the screen information of the application before modification and the screen information of the application after modification from the test code modifying device 10.
[0023] In step 3 (S3), the generation AI providing device 20 inputs the test code for the application before modification, the screen information of the application before modification, the screen information of the application after modification, and a prompt instructing the generation AI 21 to detect the difference between the screen information of the application before modification and the screen information of the application after modification, which were received in S2, and outputs the difference (i.e., the difference between the screen information of the application before modification and the screen information of the application after modification).
[0024] In step 4 (S4), the generation AI providing device 20 transmits the difference between the screen information of the application before modification and the screen information of the application after modification, which was output from the generation AI 21 in S3, to the test code modifying device 10. The test code modifying device 10 receives the difference between the screen information of the application before modification and the screen information of the application after modification from the generation AI providing device 20.
[0025] In step 5 (S5), the test code modification device 10 displays the difference between the screen information of the application before modification and the screen information of the application after modification received in S4 on the test code modification device 10 or a display connected to the test code modification device 10.
[0026] Thereafter, the user 30 checks the differences displayed in S5.
[0027] In step 6 (S6), a user 30 operating the test code modifying device 10 inputs to the test code modifying device 10 the difference between the screen information of the application before modification and the screen information of the application after modification, and a prompt instructing the test code for the application before modification to be modified.
[0028] The difference between the screen information of the application before modification and the screen information of the application after modification may be the difference sent from the generation AI providing device 20 to the test code modification device 10 in S4, or may be the difference sent from the generation AI providing device 20 to the test code modification device 10 in S4 to which the user 30 has made modifications.
[0029] In step 7 (S7), the test code modifying device 10 transmits the difference between the screen information of the application before modification and the screen information of the application after modification, which was input in S6, and a prompt instructing the device to modify the test code for the application before modification, to the device for providing generation AI 20. The device for providing generation AI 20 receives the difference between the screen information of the application before modification and the screen information of the application after modification, and the prompt instructing the device to modify the test code for the application before modification, from the test code modifying device 10.
[0030] If the difference between the screen information of the application before modification and the screen information of the application after modification is the same as the difference sent from the generation AI providing device 20 to the test code modification device 10 in S4, in S7 the test code modification device 10 may send only a prompt to the generation AI providing device 20 instructing it to modify the test code for the application before modification (i.e., do not send the difference between the screen information of the application before modification and the screen information of the application after modification, and notify the user 30 that no modifications have been made).
[0031] In step 8 (S8), the generation AI providing device 20 inputs the difference between the screen information of the application before modification and the screen information of the application after modification received in S7, and a prompt instructing the generation AI 21 to modify the test code for the application before modification, and causes the generation AI 21 to output test code for the modified application.
[0032] If the difference between the screen information of the application before modification and the screen information of the application after modification is the same as the difference sent from the generation AI providing device 20 to the test code modifying device 10, the difference may or may not be input to the generation AI. On the other hand, if the difference between the screen information of the application before modification and the screen information of the application after modification is the difference sent from the generation AI providing device 20 to the test code modifying device 10 to which the user 30 has made modifications, the difference is input to the generation AI.
[0033] In addition, in S8, the generation AI providing device 20 may input the difference between the screen information of the application before modification and the screen information of the application after modification received in S7, a prompt instructing the generation AI 21 to modify the test code for the application before modification, and also the test code before modification to the generation AI 21, thereby outputting the test code for the modified application.
[0034] In step 9 (S9), the generation AI providing device 20 transmits the test code for the modified application output from the generation AI 21 in S8 to the test code modifying device 10. The test code modifying device 10 receives the test code for the modified application from the generation AI providing device 20.
[0035] In step 10 (S10), the test code modifying device 10 displays the test code for the modified application received in S9 on the test code modifying device 10 or a display or the like connected to the test code modifying device 10.
[0036] <Function block> 3 is a functional block diagram of a test code modifying device 10 according to one embodiment of the present invention. The test code modifying device 10 can include an acquisition unit 101, a difference detection unit 102, a test code modifying unit 103, and a display unit 104. Furthermore, by executing a program, the test code modifying device 10 can function as the acquisition unit 101, the difference detection unit 102, the test code modifying unit 103, and the display unit 104. Each of these will be described below.
[0037] The acquisition unit 101 acquires a test code for the application before modification, screen information of the application before modification, screen information of the application after modification, and a prompt instructing to detect a difference between the screen information of the application before modification and the screen information of the application after modification.
[0038] For example, the acquisition unit 101 acquires the test code for the application before modification, the screen information of the application before modification, the screen information of the application after modification, and a prompt instructing the device to detect the difference between the screen information of the application before modification and the screen information of the application after modification, all of which are input by the user 30 into the test code modification device 10.
[0039] The acquisition unit 101 acquires the difference between the screen information of the application before modification and the screen information of the application after modification, and a prompt to instruct the user to modify the test code for the application before modification.
[0040] For example, the acquisition unit 101 acquires the difference between the screen information of the application before modification and the screen information of the application after modification, which are input by the user 30 into the test code modification device 10, and a prompt instructing the user to modify the test code for the application before modification.
[0041] The difference detection unit 102 inputs a test code for the application before modification, screen information of the application before modification, screen information of the application after modification, and a prompt instructing the generation AI 21 to detect a difference between the screen information of the application before modification and the screen information of the application after modification, to the generation AI 21, and causes the generation AI 21 to output a difference between the screen information of the application before modification and the screen information of the application after modification.
[0042] For example, the difference detection unit 102 transmits to the generation AI providing device 20 a test code for the application before modification, screen information of the application before modification, screen information of the application after modification, and a prompt instructing the device to detect a difference between the screen information of the application before modification and the screen information of the application after modification. The difference detection unit 102 also receives from the generation AI providing device 20 a difference between the screen information of the application before modification and the screen information of the application after modification.
[0043] The test code correction unit 103 inputs a prompt to the generation AI instructing it to correct the test code for the application before correction based on the difference between the screen information of the application before correction and the screen information of the application after correction, or the difference to which the user 30 has made modifications to the difference (note that the difference or the difference to which the user 30 has made modifications to the difference may also be input), and causes the generation AI to output the test code for the application after correction.
[0044] For example, the test code correction unit 103 transmits to the generation AI providing device 20 a prompt instructing the device 20 to correct the test code for the application before correction based on the difference between the screen information of the application before correction and the screen information of the application after correction, or the difference resulting from a modification made by the user 30 to the difference (note that the difference or the difference resulting from a modification made by the user 30 to the difference may also be transmitted). In addition, the test code correction unit 103 receives the test code for the application after correction from the generation AI providing device 20.
[0045] The display unit 104 displays the difference between the screen information of the application before modification and the screen information of the application after modification, and also displays test code for the application after modification.
[0046] [Prompt for Difference Detection] The following is an example of a prompt that instructs to detect the difference between the screen information of the application before modification and the screen information of the application after modification.
[0047] "There's a new system. The following two pieces of information will be entered, so please read the differences. For differences, please output only the difference results in table format. The table should be presented in three columns: "No.", "Title," and "Diff Result." When describing the difference results, please include the difference information on how the changes were made. For example, the granularity of the description could be, "An input field called password has been added." -System screen before change DOM:DOM_Transaction screen (transaction input) - Changed system screen DOM:DOM_02-05_Transaction screen (transaction input) Please note that the differences you read should be those related to the pre-correction test code below. ##[Test code before modification] ... (Paste the test code before modification) ... ##[System screen DOM before changes] ... (Previous screen DOM pasted) ... ##[System screen DOM after changes] ... (Paste the changed screen DOM) ..."
[0048] Thus, in one embodiment of the present invention, the test code for the application before modification, the screen information for the application before modification, and the screen information for the application after modification are pasted into a prompt that instructs the user to detect differences between the screen information for the application before modification and the screen information for the application after modification.Then, the prompt instructs the user to detect differences related to the test code for the application before modification (i.e., differences between the screen information for the application before modification and the screen information for the application after modification).
[0049] [Prompt to modify test code] Below is an example of a prompt to modify the test code for the unmodified application:
[0050] Please modify the test code provided based on the differences detected so far. Please include only test code in your answer. Do not change anything that does not need to be changed. Please do not omit any code and generate all of it, including any parts that have not been changed."
[0051] In addition, if the difference between the screen information of the application before modification and the screen information of the application after modification is the same as the difference sent from the generation AI providing device 20 to the test code modifying device 10, the difference may or may not be pasted into the prompt for modifying the test code. On the other hand, if the difference between the screen information of the application before modification and the screen information of the application after modification is the difference sent from the generation AI providing device 20 to the test code modifying device 10 to which the user 30 has made modifications, the difference is pasted into the prompt for modifying the test code.
[0052] In this way, in one embodiment of the present invention, test code for a modified application is generated by leaving the parts of the test code for the application before modification that do not require modification unchanged and changing the parts that require modification.
[0053] <Effects> In one embodiment of the present invention, test code for an application before modification can be utilized to easily generate test code for the application after modification, thereby reducing the amount of work required compared to coding the test code manually.
[0054] In one embodiment of the present invention, by inputting test code for the application before modification into the generation AI, it is possible to detect the correct differences between the screen information of the application before modification and the screen information of the application after modification. Also, in one embodiment of the present invention, by limiting the information described in the body tag of the DOM (i.e., excluding information described in the header tag (such as styles) and reducing the size of the DOM file), it is possible to improve the accuracy of detecting the differences between the screen information of the application before modification and the screen information of the application after modification.
[0055] In one embodiment of the present invention, by dividing the prompt into two, a person can eliminate unnecessary differences (differences between the screen information of the application before modification and the screen information of the application after modification) when they are detected, thereby preventing unnecessary modifications to the test code.
[0056] <Hardware configuration> 4 is a hardware configuration diagram of the test code modifying device 10 according to one embodiment of the present invention. The same applies to the generated AI providing device 20.
[0057] The test code modifying device 10 can include a control unit 1001, a main memory unit 1002, an auxiliary memory unit 1003, an input unit 1004, an output unit 1005, and an interface unit 1006. Each of these will be described below.
[0058] The control unit 1001 is a processor (for example, a CPU (Central Processing Unit), a GPU (Graphics Processing Unit), etc.) that executes various programs installed in the auxiliary storage unit 1003.
[0059] The main memory unit 1002 includes a non-volatile memory (Read Only Memory (ROM)) and a volatile memory (Random Access Memory (RAM)). The ROM stores various programs, data, etc. required for the control unit 1001 to execute various programs installed in the auxiliary memory unit 1003. The RAM provides a working area into which the various programs installed in the auxiliary memory unit 1003 are expanded when executed by the control unit 1001.
[0060] The auxiliary storage unit 1003 is an auxiliary storage device that stores various programs and information used when the various programs are executed.
[0061] The input unit 1004 is an input device through which the operator of the test code modifying apparatus 10 inputs various instructions to the test code modifying apparatus 10 .
[0062] The output unit 1005 is an output device that outputs the internal state of the test code modifying device 10 and the like.
[0063] The interface unit 1006 is a communication device for connecting to a network and communicating with other devices.
[0064] The present invention is not limited to the configurations described in the above embodiments, but may be combined with other elements, etc. These aspects can be changed without departing from the spirit of the present invention, and can be appropriately determined depending on the application form. [Explanation of symbols]
[0065] 10 Test code correction device 20 Generation AI provision device 21 Generation AI 30 users 101 Acquisition Department 102 Difference detection unit 103 Test Code Modification Section 104 Display section 1001 control section 1002 Main memory 1003 Auxiliary storage unit 1004 Input section 1005 Output section 1006 Interface section
Claims
1. A method for modifying test code of an application by a test code modification device, comprising: inputting a test code for the application before modification, screen information of the application before modification, screen information of the application after modification, and a prompt instructing the AI to detect a difference between the screen information of the application before modification and the screen information of the application after modification to the generation AI, and outputting the difference; A prompt is input to the generation AI to instruct the AI to modify the test code for the application before modification based on the difference or a difference modified by a user to the difference, and the AI is caused to output the test code for the application after modification. method.
2. The method according to claim 1 , wherein when test code for the modified application is output, the difference or a difference obtained by adding a user's modification to the difference is input to the generation AI.
3. The method of claim 1 , wherein the test is a test of a screen transition of the application.
4. The method according to claim 1 or 2, wherein the screen information is DOM (Document Object Model) information of a screen included in the application.
5. The method according to claim 4 , wherein the screen information is only information described in a body tag of the DOM.
6. A test code modification device that modifies test code of an application, comprising: a difference detection unit that inputs a test code for the application before modification, screen information of the application before modification, screen information of the application after modification, and a prompt that instructs the generation AI to detect a difference between the screen information of the application before modification and the screen information of the application after modification, to the generation AI, and causes the AI to output the difference; a test code correction unit that inputs a prompt to the generation AI to instruct the AI to correct the test code for the application before correction based on the difference or a difference obtained by a user modifying the difference, and causes the AI to output the test code for the application after correction; A test code correction device comprising:
Citation Information
Patent Citations
Test scenario execution system and test scenario execution method
JP2019003549A
Test script processing program
JP2007102654A