Testing method and device based on software downtime location
By inserting assertion detection code in test cases and executing downtime functions, the problem that traditional testing tools cannot correctly exit or locate when software downtime is encountered, achieving efficient and accurate software integration testing.
Patent Information
- Application Number
- CN202210458418.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-27
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2042-04-27
AI Technical Summary
Traditional visual software integration testing tools cannot correctly exit the test script or indicate the downtime location when the software being tested is downtime, making it difficult to quickly and accurately detect the platform software downtime, which will affect the accuracy of the test script and software integration testing. quality.
By inserting assertion detection code in the test case, if it is detected that the target data does not meet the preset conditions, the downtime function of the software being tested is executed, including the downtime processing operation leading to the security side, the updating operation of the downtime position flag and Update operation of the location flag of the downtime function to ensure the accuracy and security of the test.
It realizes rapid and accurate positioning and processing when the software being tested fails, improves the efficiency and quality of software integration testing, and ensures the accuracy and safety of test results.
Smart Images

Figure CN115033473B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a testing method and device based on software downtime positioning. Background Art
[0002] In the current era of agile testing, software version releases are becoming more and more frequent, and the goal of many companies is to quickly release high-quality software. In the field of urban rail transit, the ultimate goal is to quickly release high-quality and highly secure software. The field of urban rail transit has high requirements for software security, and any minor software defects may cause huge safety accidents during operation.
[0003] For embedded platform software commonly used in train systems, in order to ensure the safe operation of the train, there is usually a downtime requirement for the safety side that immediately terminates the platform main task and performs signal output safety shutdown when a failure is detected.
[0004] Traditional visual software integration testing tools simulate the function under test by stubbing. When the software under test crashes, they cannot exit the test script correctly or indicate where the crash occurred. Therefore, it is difficult to quickly and accurately find platform software crashes during this stage of testing, and it is difficult to ensure the correctness of the test script execution, and thus the quality of software integration testing cannot be guaranteed. Summary of the invention
[0005] The present invention provides a testing method and device based on software downtime location, which are used to solve the defect of poor quality of software integration testing in the prior art that the tested function is simulated and run by means of piling, thereby improving the quality of software testing.
[0006] The present invention provides a testing method based on software downtime positioning, comprising:
[0007] Generate a test case for the platform to be tested according to the test requirements of the software under test in the platform to be tested and the preset downtime scenario of the software under test; wherein the test case includes multiple assertion detections;
[0008] Execute the test case. During the test, if it is known based on any assertion detection that any target data in the test case does not meet the preset condition, then execute the downtime function in the test case; wherein the downtime function includes the downtime processing operation of the tested software directed to the safety side, the update operation of the downtime position mark and the update operation of the positioning mark of the downtime function; the downtime position mark includes the position mark of the tested software crashing at the correct position or the position mark of not crashing at the correct position; the positioning mark of the downtime function is used to characterize the execution position of the downtime function during the test;
[0009] The test result of the platform to be tested is output according to the updated downtime position mark and the updated positioning mark of the downtime function.
[0010] According to a testing method based on software downtime location provided by the present invention, the test result of the platform to be tested is output according to the updated downtime location mark and the updated downtime function location mark, including:
[0011] When the updated positioning mark of the downtime function is the expected positioning mark, and the updated downtime position mark is the position mark where the tested software crashes at the correct position, the test result of the platform to be tested is determined to be passed.
[0012] According to a test method based on software downtime location provided by the present invention, an update operation of a downtime location flag in a downtime function in the test case is performed, comprising:
[0013] When the execution position of the downtime function is consistent with the expected downtime position, the downtime position mark is updated to the position mark where the tested software downtime occurs at the correct position;
[0014] When the execution position of the crash function is inconsistent with the expected crash position, the crash position flag is updated to a position flag indicating that the tested software does not crash at the correct position.
[0015] According to a testing method based on software downtime location provided by the present invention, after executing the downtime function in the test case, the method further includes:
[0016] After any of the assertion detections is completed, if it is determined that the updated downtime location mark is different from the initial downtime location mark, the test is exited.
[0017] According to a testing method based on software downtime location provided by the present invention, the test case of the platform to be tested is generated according to the test requirements of the software under test in the platform to be tested and the preset downtime scenario of the software under test, including:
[0018] According to the test requirements of the software under test, the use case design method is used to generate the initial test cases of the platform to be tested; wherein the use case design method includes one or more combinations of scenario method, equivalence class partitioning method, boundary value analysis method, and error guessing method;
[0019] According to the preset downtime scenario of the software under test, determining the target location of the assertion detection to be added in the initial test case;
[0020] An assertion check is added at the target position in the initial test case to obtain the test case.
[0021] According to a test method based on software downtime location provided by the present invention, after outputting the test result of the platform to be tested according to the updated downtime location mark and the updated location mark of the downtime function, the method further includes:
[0022] In the case where the test result is that the test fails, locating the downtime position of the tested software according to the updated downtime position mark and the updated positioning mark of the downtime function;
[0023] The software under test is debugged according to the crash location of the software under test.
[0024] According to a testing method based on software downtime location provided by the present invention, the test data corresponding to the test case is pre-selected and obtained according to a preset downtime scenario of the tested software.
[0025] The present invention also provides a testing device based on software downtime positioning, comprising:
[0026] A use case generation module is used to: generate a test case for the platform to be tested according to the test requirements of the software under test in the platform to be tested and the preset downtime scenario of the software under test; wherein the test case includes multiple assertion detections;
[0027] A test execution module, used for: executing the test case, during the test process, if it is known based on any assertion detection that any target data in the test case does not meet the preset condition, then executing the downtime function in the test case; wherein the downtime function includes the downtime processing operation of the tested software directed to the safety side, the update operation of the downtime position mark and the update operation of the positioning mark of the downtime function; the downtime position mark includes the position mark of the tested software crashing at the correct position or the position mark of not crashing at the correct position; the positioning mark of the downtime function is used to characterize the execution position of the downtime function in the test process;
[0028] The test output module is used to output the test result of the platform to be tested according to the updated downtime position mark and the updated positioning mark of the downtime function.
[0029] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a test method based on software downtime location as described above is implemented.
[0030] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the test method based on software downtime location as described in any one of the above is implemented.
[0031] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned testing methods based on software downtime location.
[0032] The testing method and device based on software downtime location provided by the present invention insert assertion detection code in the test case, so that when any target data obtained in any assertion detection does not meet the preset conditions, the downtime processing operation directed to the safety side of the tested software is timely performed to ensure the operation safety of the platform to be tested; at the same time, the downtime position mark and the positioning mark of the downtime function are updated, and the downtime test result of the platform to be tested is determined according to the updated downtime position mark and the updated positioning mark of the downtime function; when the tested software crashes, the downtime situation is discovered in time and the downtime position is accurately located according to the downtime test result, so as to effectively simulate various downtime scenarios when the platform to be tested is actually running, realize the accurate positioning of the downtime position of the tested software in the platform to be tested and correctly execute the automatic test script, and improve the efficiency and test quality of software integration testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0034] Figure 1 This is one of the flow charts of the testing method based on software downtime location provided by the present invention;
[0035] Figure 2 This is the second flow chart of the testing method based on software downtime location provided by the present invention;
[0036] Figure 3 This is the third flow chart of the testing method based on software downtime location provided by the present invention;
[0037] Figure 4 It is a structural schematic diagram of a testing device based on software downtime location provided by the present invention;
[0038] Figure 5 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0040] Traditional visual software integration testing tools simulate the function under test by stubbing. When the software under test crashes, they cannot exit the test script correctly or indicate where the crash occurred. Therefore, it is difficult to quickly and accurately find platform software crashes during this stage of testing, and it is difficult to ensure the correctness of the test script execution, and thus the quality of software integration testing cannot be guaranteed.
[0041] In order to solve the above problems, the embodiment of the present application provides a test method based on software downtime location, which is based on the method of inserting code to perform downtime location integration test on the software under test of the test platform, and is applicable to the field of software testing technology for rail transit signal systems. The method specifically includes: designing test cases using a black box test method according to the functional module requirement design specification of the software under test in the test platform, and determining a gray box test strategy; selecting test data based on different scenarios of the software under test in the test platform that are directed to the safety side; and dynamically executing test cases driven by the software through test data to test the correctness of the downtime location of the software under test in the test platform, so as to meet the requirements for software integration testing in the functional safety standard EN50128 tailored to the specific needs of the railway industry. Through the use of inserting test code, the present application effectively covers the gray box test of the scenario that requires downtime to be directed to the safety side in the design requirements, thereby improving the efficiency and test quality of software integration testing.
[0042] Combine the following Figure 1 The present invention describes a testing method based on software downtime location, which includes the following steps:
[0043] Step 101, generating a test case for the platform to be tested according to the test requirements of the software under test in the platform to be tested and the preset downtime scenario of the software under test; wherein the test case includes multiple assertion detections;
[0044] The platform to be tested is a platform that needs to perform software testing, including but not limited to other embedded platforms such as a train automatic control platform or a train operation management platform, and this embodiment does not make specific limitations on this.
[0045] The platform to be tested includes one or more software to be tested, and the specific number can be set according to actual needs.
[0046] Assertions are a type of first-order logic in a program. Their purpose is to express and verify the results expected by software developers. When the program executes to the assertion position, the corresponding assertion should be true. If the assertion is not true, the program will terminate execution and give an error message.
[0047] Optionally, when software testing is required on the test platform, the test requirements of the software under test can be pre-generated based on the functional requirements of the software under test, and the preset downtime scenario of the software under test can be pre-set in combination with all situations that may cause the platform to be directed to the safety side (i.e., downtime).
[0048] Then, a test case is generated in combination with the test requirements of the software under test in the platform to be tested and the preset downtime scenario, and multiple assertion detections are set in the test case; wherein, the setting method of the assertion detection side can be set by the user according to actual needs, or it can be automatically set according to the test requirements of the software under test and / or the preset downtime scenario, and this embodiment does not make specific limitations on this.
[0049] At the same time, obtain the test data corresponding to the test case;
[0050] It should be noted that after obtaining the test cases, in order to improve the test efficiency, the test cases can be converted into automatically executable test scripts.
[0051] Step 102, executing the test case. During the test, if any target data in the test case is found to not satisfy a preset condition based on any assertion detection, then executing the downtime function in the test case; wherein the downtime function includes a downtime processing operation directed to the safety side of the tested software, an update operation of a downtime position mark, and an update operation of a positioning mark of the downtime function; the downtime position mark includes a position mark indicating that the tested software has crashed at the correct position or a position mark indicating that the software has not crashed at the correct position; the positioning mark of the downtime function is used to characterize the execution position of the downtime function during the test;
[0052] Among them, the crash location flag is a global integer variable pre-defined in the crash function, which is used to mark whether the software under test has crashed and whether the crash occurred at the correct location; the crash location flag includes a location flag where the software under test crashed at the correct location or a location flag where the crash did not occur at the correct location; wherein, the situation where the crash did not occur at the correct location includes the situation where the crash occurred before the correct location.
[0053] The location flag of the crash function is a global integer variable pre-defined in the crash function, which is used to mark the execution position of the crash function in this test, that is, the number of times the crash function is entered in this test, or the execution position of this assertion detection in the entire program flow.
[0054] The target data is the key data in the test case that affects the test results. The preset conditions are the expected conditions for determining whether the tested software has crashed, which can be set according to the test requirements.
[0055] The downtime function includes not only the downtime processing operation of the tested software directed to the safety side, but also the updating operation of the downtime position mark and the updating operation of the positioning mark of the downtime function.
[0056] The downtime operation directed to the safety side is an operation directed to the safety side that immediately terminates the main task of the platform to be tested and performs a signal output safety shutdown when a downtime of the software under test is detected.
[0057] Optionally, after the test case and the test data are acquired, the automatically executable test script may be dynamically executed by driving the test data to automatically execute the test case.
[0058] like Figure 2 As shown, during the execution of the test case, each assertion detection result is monitored in real time. If it is determined that any target data in the test case does not meet the preset conditions according to the detection result of any assertion detection, it is determined that the software under test has crashed. In order to ensure the safe operation of the platform software to be tested, in this scenario, the execution node of the current program is triggered to enter the crash function, and the crash processing operation directed to the safe side in the crash function is executed to guide the software under test of the platform to be tested to the safe side.
[0059] In order to accurately obtain the test results, it is necessary to synchronously execute the update operation of the downtime position flag and the update operation of the downtime function positioning flag to update the downtime position flag and the positioning flag of the downtime function, and then determine whether the software under test has passed the downtime test and locate the location where the downtime occurs based on the updated downtime position flag and the updated positioning flag of the downtime function.
[0060] Step 103: output the test result of the platform to be tested according to the updated downtime position mark and the updated positioning mark of the downtime function.
[0061] Optionally, after obtaining the updated downtime position flag and the updated downtime function positioning flag, it is possible to determine in real time whether the software under test is experiencing abnormal downtime according to the updated downtime position flag and the updated downtime function positioning flag;
[0062] When it is determined that the software under test has experienced an abnormal downtime, it is determined that the software under test has failed the software test; when it is determined that the software under test has not experienced an abnormal downtime, it is determined that the software under test has passed the software test.
[0063] It should be noted that the test method based on software downtime location in this implementation can be to build a test platform in the software environment to simulate software testing on the platform to be tested, which provides a fast and efficient method for developers to simulate downtime and locate defects without using real hardware boards and actual operating data; it can also be to burn the fault core code written according to the test case in the real platform hardware board to perform system testing. Among them, although it takes a long time and requires high hardware costs to perform system testing using the actual hardware board operating environment equipped with the platform software under test, it can test software and hardware problems at the same time, as well as software problems caused by actual hardware that cannot be discovered by testing the software alone. The specific application scenario of the test method can be set according to actual needs.
[0064] This embodiment inserts assertion detection code in the test case so that when any target data obtained in any assertion detection does not meet the preset conditions, the software under test is promptly processed to the safety side to ensure the safe operation of the platform under test; at the same time, the downtime position flag and the positioning flag of the downtime function are updated, and the downtime test result of the platform under test is determined according to the updated downtime position flag and the updated positioning flag of the downtime function; when the software under test crashes, the crash situation is discovered in time and the crash location is accurately located according to the downtime test result, effectively simulating various crash scenarios during the actual operation of the platform under test, realizing the precise positioning of the crash location of the software under test in the platform under test and the correct execution of the automatic test script, thereby improving the efficiency and test quality of software integration testing.
[0065] On the basis of the above-mentioned embodiments, the test result of the platform to be tested is output according to the updated downtime position mark and the updated positioning mark of the downtime function in this embodiment, including: when the positioning mark of the updated downtime function is the expected positioning mark, and the updated downtime position mark is the position mark where the software under test crashes at the correct position, determining that the test result of the platform to be tested is a passed test.
[0066] The expected positioning flag is a global integer array variable pre-defined according to actual needs, and the expected positioning flag is used to mark the expected downtime position of this test.
[0067] Optionally, after obtaining the updated downtime location flag, it can be determined whether the updated downtime location flag and the updated downtime function location flag both meet the normal downtime condition of the software under test;
[0068] The specific judgment method includes judging whether the updated downtime location mark is the location mark where the software under test crashes at the correct location, and whether the positioning mark of the updated downtime function is the expected positioning mark. If both are satisfied, it indicates that the platform under test has a normal downtime, and it is determined that the platform under test has passed the test.
[0069] If one of the two conditions is not satisfied, it indicates that the platform to be tested has an abnormal downtime, that is, the downtime does not occur at the correct location, and it is determined that the platform to be tested has failed the test.
[0070] This embodiment can quickly and accurately obtain the test result of the platform to be tested according to the updated downtime location mark.
[0071] On the basis of the above-mentioned embodiment, the present embodiment performs an update operation of the crash position flag in the crash function in the test case, including: when the execution position of the crash function is consistent with the expected crash position, updating the crash position flag to a position flag where the software under test crashes at the correct position; when the execution position of the crash function is inconsistent with the expected crash position, updating the crash position flag to a position flag where the software under test does not crash at the correct position.
[0072] The expected downtime position is a normal downtime position set according to a preset downtime scenario of the software under test.
[0073] In addition to the downtime processing related operations of the tested software itself that guide the safety side, the downtime function also adds a function to determine whether the downtime function entered in this test is the expected downtime position of the test;
[0074] like Figure 3 As shown, the execution position of the crash function is compared with the expected crash position. If the execution position of the crash function is the crash position expected by the test, the crash position flag is updated to the position flag where the software under test crashes at the correct position; if not, the crash position flag is updated to the position flag where the software under test crashes at an incorrect position, such as a crash before the correct position.
[0075] This embodiment inserts a crash position judgment operation in the crash function to compare the execution position of the crash function with the expected crash position, so that the crash position flag can be updated quickly and conveniently, effectively simulating the crash scenario during actual platform operation, locating the crash scenario of the software under test and correctly executing the automatic test script, thereby improving the efficiency and test quality of software integration testing.
[0076] On the basis of the above embodiments, in this embodiment, after the execution of the downtime function in the test case, the method also includes: after any of the assertion detections is completed, if it is determined that the updated downtime position mark is different from the initial downtime position mark, then exiting the test.
[0077] The initial downtime position mark is an initial position mark without downtime.
[0078] Optionally, after any assertion detection is completed, that is, after the assertion is exited, it is determined whether the updated downtime position mark is the same as the initial downtime position mark;
[0079] If the updated crash location flag is different from the initial crash location flag, it is determined that the software under test has crashed. In this scenario, the test is directly exited, and the test results of the platform under test are output based on the updated crash location flag and the updated crash function location flag obtained during the assertion detection process.
[0080] In the prior art, when the software under test crashes, it is impossible to correctly exit the test script or to indicate the location where the crash occurs, that is, the test program enters an infinite loop, and the correctness of the test script execution cannot be guaranteed.
[0081] This example can determine in real time whether the software under test has crashed, and when the software under test crashes, it can jump from the current test program to the exit of the tested function in time, exit the test in time, and output correct test results.
[0082] On the basis of the above-mentioned embodiments, the test case of the platform to be tested is generated according to the test requirements of the software under test in the platform to be tested and the preset downtime scenario of the software under test in the present embodiment, including: the test case of the platform to be tested is generated according to the test requirements of the software under test in the platform to be tested and the preset downtime scenario of the software under test, including: according to the test requirements of the software under test, using the use case design method to generate the initial test case of the platform to be tested; wherein the use case design method includes one or more combinations of the scenario method, the equivalence class partitioning method, the boundary value analysis method and the error guessing method; according to the preset downtime scenario of the software under test, determining the target position to be added with the assertion detection in the initial test case; adding the assertion detection at the target position in the initial test case to obtain the test case.
[0083] Among them, use case design methods include but are not limited to use case design methods related to black box testing and use case design methods related to gray box testing, specifically including scenario method, equivalence class division method, boundary value analysis method, error guessing method and other software compilation methods.
[0084] The target location is the location in the initial test case where assertion detection needs to be added.
[0085] Optionally, firstly, according to the test requirements of the software under test, the initial test cases for software integration are compiled by using the scenario method, equivalence class division method, boundary value analysis method, error guessing method, etc.;
[0086] Then, according to the preset crash scenario of the software under test, the preset location where the software under test crashes is determined in the initial test case, and the preset location where the crash occurs is used as the target location to be added with assertion detection;
[0087] Then, assertion detection is added at the target location in the initial test case to obtain the test case.
[0088] like Figure 2 As shown in the figure, the test case contains multiple program function implementation codes, such as program function implementation 1, program function implementation 2, and program function implementation 3, and each program function implementation process is prone to crash. Therefore, an assertion test can be added at the end of each program function implementation code, such as assertion test 1 is set after program function implementation 1, assertion test 2 is set after program function implementation 2, and assertion test 3 is set after program function implementation 3. If any assertion test process finds that the software under test crashes, it will directly jump to the exit of the function under test to exit the test.
[0089] This embodiment integrates the test requirements of the software under test and the preset downtime scenarios of the software under test, and can quickly and accurately integrate the test cases of the platform to be tested, and inserts assertion detection in the test cases according to the preset downtime scenarios of the software under test, effectively covering the downtime scenario tests in the platform to be tested, thereby improving the efficiency and quality of software testing.
[0090] On the basis of the above embodiments, in this embodiment, after outputting the test result of the platform to be tested according to the updated downtime location mark, the method also includes: when the test result is failure, locating the downtime location of the software under test according to the updated downtime location mark, and debugging the software under test according to the downtime location of the software under test.
[0091] Optionally, after obtaining the test results of the platform to be tested, it is also possible to determine whether the software under test of the platform to be tested has passed the test according to the test results;
[0092] When the test result is that the test fails, the crash location of the tested software can be located according to the updated crash location flag and the updated crash function location flag;
[0093] The crash location is used to characterize the number of test cycles in which the software under test crashes, and at which location in the test case the crash occurs.
[0094] According to the downtime location, the input defects of the test data or the code defects in the software under test are located, and then the software under test is debugged according to the input defects or the code defects.
[0095] This embodiment can not only test the platform to be tested, but also locate the crash location of the software to be tested in time when the test result is that the test fails, and debug the software to be tested in time according to the crash location of the software to be tested. The platform software crash location integration test based on the instrumented test code can be used not only for testing by testers, but also for obtaining the test results of any functional program of the platform to be tested by setting assertion detection in the system program, which can be used by software developers to call local functional modules to quickly locate code defects, reduce the time cost and economic cost of debugging in the hardware environment, and improve maintenance efficiency.
[0096] On the basis of the above-mentioned embodiment, the test data corresponding to the test case in this embodiment is pre-selected and obtained according to the preset downtime scenario of the software under test.
[0097] Optionally, when determining the test data, relevant test data can be selected from the parameters of the software under test based on different preset downtime scenarios of the software under test, so as to effectively simulate the software downtime scenarios and effectively simulate the downtime scenarios during the actual operation of the platform to be tested, thereby improving the efficiency and test quality of software integration testing.
[0098] The following is a detailed description of the overall process of the testing method based on software downtime location provided by this implementation.
[0099] The method mainly includes the following steps:
[0100] Step 1: Analyze the downtime scenarios according to the test function requirements of the software under test in the platform to be tested, combine all situations that may cause the platform to be tested to be directed to the safety side (i.e., downtime), use scenario method, equivalence class division method, boundary value analysis method, error guessing method, etc. to compile software integration test cases, and input the test data into an automatically executable test script.
[0101] Step 2, define the global integer variable crash position flag, which is used to indicate whether the software under test crashes and whether the crash occurs at the correct position; define the global integer variable crash function positioning flag, which is used to indicate the number of times the crash function is entered, that is, the execution position of this assertion test in the entire program flow; define the global integer array variable crash positioning array to mark the expected crash position of this test.
[0102] Step 3. According to the scenarios designed in the integrated test cases, add assertion detection at the locations of abnormal scenarios where the software under test may crash. When it is detected that key data does not meet expectations, enter the crash function. After exiting the assertion, if the crash location flag is not the initial value, directly jump to the exit of the function under test, that is, exit the test.
[0103] Among them, in the downtime function, in addition to the downtime processing related operations of the tested software itself that guides the safety side, it is added to judge whether the execution position of the downtime function entered this time is the expected downtime position. If so, the downtime position is marked as a downtime at the correct position. If not, the downtime position is marked as a downtime not at the correct position, such as the downtime occurs before the correct position.
[0104] At the same time, during the execution of the downtime function, the positioning flag of the variable downtime function and the value x in the expected downtime scenario are monitored using the software debugging method to determine whether the software under test crashes at the expected location. Among them, if the xth element of the downtime positioning array is assigned the expected downtime.
[0105] Step 4, check the execution results of the test script that has been automatically executed. If the output downtime position mark indicates that the system crashed at the correct position, the test has passed. If the output downtime position mark indicates that the system crashed before the correct position, it can be considered that the expected result is inconsistent with the actual result, and the debugging software can be used to locate the test data input defect or code defect.
[0106] The test device based on software downtime location provided by the present invention is described below. The test device based on software downtime location described below and the test method based on software downtime location described above can refer to each other.
[0107] like Figure 4 As shown, this embodiment provides a test device based on software downtime location, the device includes: a use case generation module 401, a test execution module 402 and a test output module 403, wherein:
[0108] The use case generation module 401 is used to: generate a test case for the platform to be tested according to the test requirements of the software under test in the platform to be tested and the preset downtime scenario of the software under test; wherein the test case includes multiple assertion detections;
[0109] Optionally, when software testing is required on the platform under test, the test requirements of the software under test can be pre-generated based on the functional requirements of the software under test, and the preset downtime scenarios of the software under test can be pre-set in combination with all situations that may cause the platform to be oriented to the security side.
[0110] Then, a test case is generated in combination with the test requirements of the software under test in the platform to be tested and the preset downtime scenario, and multiple assertion detections are set in the test case; wherein, the setting method of the assertion detection side can be set by the user according to actual needs, or it can be automatically set according to the test requirements of the software under test and / or the preset downtime scenario, and this embodiment does not make specific limitations on this.
[0111] At the same time, obtain the test data corresponding to the test case;
[0112] After obtaining the test cases, in order to improve the testing efficiency, the test cases can be converted into automatically executable test scripts.
[0113] The test execution module 402 is used to: execute the test case, and during the test process, if it is known based on any assertion detection that any target data in the test case does not meet the preset condition, then execute the downtime function in the test case; wherein the downtime function includes the downtime processing operation of the tested software directed to the safety side, the update operation of the downtime position mark and the update operation of the positioning mark of the downtime function; the downtime position mark includes the position mark of the tested software crashing at the correct position or the position mark of not crashing at the correct position; the positioning mark of the downtime function is used to represent the execution position of the downtime function in the test process;
[0114] During the execution of the test case, each assertion detection result is monitored in real time. If any target data in the test case does not meet the preset conditions according to the detection result of any assertion detection, it is determined that the software under test has crashed. In order to ensure the safe operation of the platform software to be tested, in this scenario, the execution node of the current program is controlled to enter the crash function, and the crash processing operation directed to the safe side in the crash function is executed to guide the software under test of the platform to be tested to the safe side.
[0115] In order to accurately obtain the test results, it is necessary to synchronously execute the update operation of the downtime position flag and the update operation of the downtime function positioning flag to update the downtime position flag and the positioning flag of the downtime function, and then determine whether the software under test has passed the downtime test and locate the location where the downtime occurs based on the updated downtime position flag and the updated positioning flag of the downtime function.
[0116] The test output module 403 is used to output the test result of the platform to be tested according to the updated downtime position mark and the updated positioning mark of the downtime function.
[0117] Optionally, after obtaining the updated downtime position flag and the updated downtime function positioning flag, it is possible to determine in real time whether the software under test is experiencing abnormal downtime according to the updated downtime position flag and the updated downtime function positioning flag;
[0118] When it is determined that the software under test has experienced an abnormal downtime, it is determined that the software under test has failed the software test; when it is determined that the software under test has not experienced an abnormal downtime, it is determined that the software under test has passed the software test.
[0119] This embodiment inserts assertion detection code in the test case so that when any target data obtained in any assertion detection does not meet the preset conditions, the software under test is promptly processed to the safety side to ensure the safe operation of the platform under test; at the same time, the downtime position flag and the positioning flag of the downtime function are updated, and the downtime test result of the platform under test is determined according to the updated downtime position flag and the updated positioning flag of the downtime function; when the software under test crashes, the crash situation is discovered in time and the crash location is accurately located according to the downtime test result, effectively simulating various crash scenarios during the actual operation of the platform under test, realizing the precise positioning of the crash location of the software under test in the platform under test and the correct execution of the automatic test script, thereby improving the efficiency and test quality of software integration testing.
[0120] On the basis of the above-mentioned embodiment, the test output module in this embodiment is specifically used for: when the positioning mark of the updated downtime function is the expected positioning mark, and the updated downtime position mark is the position mark where the tested software crashes at the correct position, determining that the test result of the platform to be tested is a passed test.
[0121] On the basis of the above-mentioned embodiments, the test execution module in this embodiment is specifically used for: when the execution position of the crash function is consistent with the expected crash position, updating the crash position flag to a position flag indicating that the software under test crashes at the correct position; when the execution position of the crash function is inconsistent with the expected crash position, updating the crash position flag to a position flag indicating that the software under test does not crash at the correct position.
[0122] Based on the above embodiments, this embodiment also includes a test exit module, which is specifically used to: after any assertion detection is completed, if it is determined that the updated downtime location mark is different from the initial downtime location mark, then exit the test.
[0123] On the basis of the above embodiments, the use case generation module in this embodiment is specifically used to: generate initial test cases for the platform to be tested by using a use case design method according to the test requirements of the software under test; wherein the use case design method includes one or more combinations of a scenario method, an equivalence class partitioning method, a boundary value analysis method, and an error guessing method; determine the target position to be added with an assertion check in the initial test case according to the preset downtime scenario of the software under test; add an assertion check at the target position in the initial test case to obtain the test case.
[0124] On the basis of the above embodiments, the present embodiment also includes a software debugging module, which is specifically used for: when the test result is failure of the test, locating the crash location of the software under test according to the updated crash location mark and the updated crash function positioning mark; and debugging the software under test according to the crash location of the software under test.
[0125] On the basis of the above-mentioned embodiments, the test data corresponding to the test case in this embodiment is pre-selected and obtained according to the preset downtime scenario of the software under test.
[0126] Figure 5 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 5 As shown, the electronic device may include: a processor (processor) 501, a communication interface (Communications Interface) 502, a memory (memory) 503 and a communication bus 504, wherein the processor 501, the communication interface 502, and the memory 503 communicate with each other through the communication bus 504. The processor 501 can call the logic instructions in the memory 503 to execute a test method based on software downtime location, the method comprising: generating a test case for the platform to be tested according to the test requirements of the software under test in the platform to be tested and the preset downtime scenario of the software under test; wherein the test case includes multiple assertion detections; executing the test case, during the test process, if it is known based on any assertion detection that any target data in the test case does not meet the preset conditions, then executing the downtime function in the test case; wherein the downtime function includes the downtime processing operation of the software under test directed to the safety side, the update operation of the downtime position mark and the update operation of the positioning mark of the downtime function; the downtime position mark includes the position mark of the software under test that has crashed at the correct position or the position mark of the software under test that has not crashed at the correct position; the positioning mark of the downtime function is used to characterize the execution position of the downtime function during the test; and outputting the test result of the platform to be tested according to the updated downtime position mark and the updated positioning mark of the downtime function.
[0127] In addition, the logic instructions in the above-mentioned memory 503 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0128] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the test method based on software downtime location provided by the above methods, the method comprising: generating a test case for the platform to be tested according to the test requirements of the software under test in the platform to be tested and the preset downtime scenario of the software under test; wherein the test case includes multiple assertion detections; executing the test case, during the test process, if any of the test cases in the test case is found to be down based on any assertion detection If the target data does not meet the preset conditions, the downtime function in the test case is executed; wherein the downtime function includes the downtime processing operation of the tested software directed to the safety side, the update operation of the downtime position mark and the update operation of the positioning mark of the downtime function; the downtime position mark includes the position mark that the tested software crashes at the correct position or the position mark that the software does not crash at the correct position; the positioning mark of the downtime function is used to characterize the execution position of the downtime function in the test process; according to the updated downtime position mark and the updated positioning mark of the downtime function, the test result of the platform to be tested is output.
[0129] On the other hand, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it is implemented to execute the test method based on software downtime location provided by the above-mentioned methods, the method comprising: generating a test case of the platform to be tested according to the test requirements of the software under test in the platform to be tested and the preset downtime scenario of the software under test; wherein the test case contains multiple assertion detections; executing the test case, during the test process, if it is known based on any assertion detection that any target data in the test case does not meet the preset conditions, then executing the downtime function in the test case; wherein the downtime function includes the downtime processing operation of the software under test directed to the safety side, the update operation of the downtime position mark and the update operation of the positioning mark of the downtime function; the downtime position mark includes the position mark of the software under test that crashes at the correct position or the position mark of the software under test that does not crash at the correct position; the positioning mark of the downtime function is used to characterize the execution position of the downtime function during the test; according to the updated downtime position mark and the updated positioning mark of the downtime function, the test result of the platform to be tested is output.
[0130] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0131] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0132] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A testing method based on software downtime location, characterized in that: include: Generate a test case for the platform to be tested according to the test requirements of the software under test in the platform to be tested and the preset downtime scenario of the software under test; wherein the test case includes multiple assertion detections; Execute the test case. During the test, if it is known based on any assertion detection that any target data in the test case does not meet the preset condition, then execute the downtime function in the test case; wherein the downtime function includes the downtime processing operation of the tested software directed to the safety side, the update operation of the downtime position mark and the update operation of the positioning mark of the downtime function; the downtime position mark includes the position mark of the tested software crashing at the correct position or the position mark of not crashing at the correct position; the positioning mark of the downtime function is used to characterize the execution position of the downtime function during the test; Outputting the test result of the platform to be tested according to the updated downtime position mark and the updated positioning mark of the downtime function; Outputting the test result of the platform to be tested according to the updated downtime position mark and the updated positioning mark of the downtime function includes: When the updated positioning mark of the downtime function is the expected positioning mark, and the updated downtime position mark is the position mark where the tested software crashes at the correct position, the test result of the platform to be tested is determined to be passed.
2. The testing method based on software downtime location according to claim 1, characterized in that: Executing an update operation of a downtime position flag in a downtime function in the test case includes: When the execution position of the downtime function is consistent with the expected downtime position, the downtime position mark is updated to the position mark where the tested software downtime occurs at the correct position; When the execution position of the crash function is inconsistent with the expected crash position, the crash position flag is updated to a position flag indicating that the tested software does not crash at the correct position.
3. The testing method based on software downtime location according to any one of claims 1-2, characterized in that: After executing the downtime function in the test case, the method further includes: After any of the assertion detections is completed, if it is determined that the updated downtime location mark is different from the initial downtime location mark, the test is exited.
4. The testing method based on software downtime location according to any one of claims 1-2, characterized in that: The generating of the test case of the platform to be tested according to the test requirements of the software to be tested in the platform to be tested and the preset downtime scenario of the software to be tested includes: According to the test requirements of the software under test, an initial test case of the platform to be tested is generated by using a use case design method; wherein the use case design method includes one or more combinations of a scenario method, an equivalence class partitioning method, a boundary value analysis method, and an error guessing method; According to the preset downtime scenario of the software under test, determining the target location of the assertion detection to be added in the initial test case; An assertion check is added at the target position in the initial test case to obtain the test case.
5. The testing method based on software downtime location according to any one of claims 1-2, characterized in that: After outputting the test result of the platform to be tested according to the updated downtime position mark and the updated positioning mark of the downtime function, the method further includes: In the case where the test result is that the test fails, locating the downtime position of the tested software according to the updated downtime position mark and the updated positioning mark of the downtime function; The software under test is debugged according to the crash location of the software under test.
6. The testing method based on software downtime location according to any one of claims 1-2, characterized in that: The test data corresponding to the test case is pre-selected and obtained according to a preset downtime scenario of the software under test.
7. A testing device based on software downtime location, characterized in that: include: A use case generation module is used to: generate a test case for the platform to be tested according to the test requirements of the software under test in the platform to be tested and the preset downtime scenario of the software under test; wherein the test case includes multiple assertion detections; A test execution module, used for: executing the test case, during the test process, if it is known based on any assertion detection that any target data in the test case does not meet the preset condition, then executing the downtime function in the test case; wherein the downtime function includes the downtime processing operation of the tested software directed to the safety side, the update operation of the downtime position mark and the update operation of the positioning mark of the downtime function; the downtime position mark includes the position mark of the tested software crashing at the correct position or the position mark of not crashing at the correct position; the positioning mark of the downtime function is used to characterize the execution position of the downtime function in the test process; A test output module, used to: output the test result of the platform to be tested according to the updated downtime position mark and the updated positioning mark of the downtime function; The test output module is specifically used for: When the updated positioning mark of the downtime function is the expected positioning mark, and the updated downtime position mark is the position mark where the tested software crashes at the correct position, the test result of the platform to be tested is determined to be passed.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the test method based on software downtime location as described in any one of claims 1 to 6 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the testing method based on software downtime location as claimed in any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Method, device, equipment and system for monitoring running state of service system
CN110784374A
A server downtime stage positioning method and system, a terminal and a storage medium
CN112486785A