Log output method and device, electronic equipment and readable storage medium
By using trace identification information to generate log files in software debugging, the problem of low log viewing efficiency after test cases fails is solved, and rapid positioning and output logs are achieved, which improves testing efficiency.
Patent Information
- Application Number
- CN202411201152.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-29
- Publication Date
- 2024-12-03
AI Technical Summary
During software debugging, after the test case runs, testers need to re-execute the failed test case to view the business log, resulting in inefficiency in testing, especially when there are too many failed test cases, which consumes a lot of time and effort.
By using trace identification information in test cases, generating and outputting the log file corresponding to the target test case, using trace identification information in context variables to accurately identify and output logs for characterizing the execution process of the target test case, improving Test efficiency.
It implements the logs of target test cases that fail to execute quickly from a large number of test cases, reducing tester workload and improving test efficiency and reliability.
Smart Images

Figure CN119065980A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information processing technology, and in particular to a log output method, device, electronic device and readable storage medium. Background Art
[0002] During software development and maintenance, the purpose of software debugging is to discover and fix errors in the software. During software debugging, a large number of test cases need to be executed. Currently, after a test case fails, the tester needs to re-execute the failed test cases one by one to view the business logs of the failed test cases. When there are too many failed test cases, the tester needs to spend a lot of time and energy to re-execute the test cases, resulting in low testing efficiency. Summary of the invention
[0003] The purpose of the embodiments of the present invention is to provide a log output method, device, electronic device and readable storage medium, which can improve the test efficiency. The specific technical solutions are as follows:
[0004] In a first aspect of the present invention, a log output method is provided, comprising:
[0005] Execute multiple test cases to obtain a first test result of each test case; one test case is associated with a context variable, and the context variable includes tracking identification information;
[0006] In the case where the first test result of the target test case does not match the preset test result, determining the tracking identification information in the context variable associated with the target test case; the multiple test cases include the target test case;
[0007] A first log file corresponding to the target test case is generated and output according to the tracking identification information, wherein the first log file includes first identification information, and the first identification information includes tracking identification information associated with the target test case.
[0008] In a second aspect of the present invention, a log output device is provided, comprising:
[0009] An execution module is used to execute multiple test cases and obtain a first test result of each test case; one test case is associated with a context variable, and the context variable includes tracking identification information;
[0010] A determination module, configured to determine, when a first test result of a target test case does not match a preset test result, the tracking identification information in a context variable associated with the target test case; the target test case is included in the plurality of test cases;
[0011] The output module is used to generate and output a first log file corresponding to the target test case according to the tracking identification information, wherein the first log file includes the first identification information, and the first identification information includes the tracking identification information associated with the target test case.
[0012] In another aspect of the present invention, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is run on a computer, the computer executes any of the above-mentioned data forwarding methods.
[0013] In another aspect of the present invention, a computer program product including instructions is provided, which, when executed on a computer, enables the computer to execute any of the log output methods described above.
[0014] The log output method provided by the embodiment of the present invention obtains the first test result of each test case by executing multiple test cases; one test case is associated with a context variable, and the context variable includes tracking identification information; when the first test result of the target test case does not match the preset test result, the tracking identification information in the context variable associated with the target test case is determined; the multiple test cases include the target test case; here, the tracking identification information associated with the target test case that failed to execute can be determined from a large number of test cases. Finally, the first log file corresponding to the target test case is generated and output according to the tracking identification information, wherein the first log file includes the first identification information, and the first identification information includes the tracking identification information associated with the target test case. Therefore, through the tracking identification information in the context variable, the log used to characterize the execution process of the target test case can be accurately identified from a large number of logs, and the first log file can be output according to the tracking identification information, thereby improving the test efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.
[0016] Figure 1 is a flow chart of a log output method provided by an embodiment of the present invention;
[0017] Figure 2 It is a schematic diagram of the architecture of a log output method provided by an embodiment of the present invention;
[0018] Figure 3 It is a schematic diagram of the architecture of another log output method provided by an embodiment of the present invention;
[0019] Figure 4 It is a structural schematic diagram of a log output device provided by an embodiment of the present invention;
[0020] Figure 5 It is a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0021] The technical solutions in the embodiments of the present invention will be described below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0022] Figure 1 A flow chart of a log output method provided by an embodiment of the present invention. Figure 1 As shown, the log output method may include steps 110 to 130, and the method is applied to a log output device, as shown below:
[0023] Step 110, executing multiple test cases to obtain a first test result of each test case; one test case is associated with a context variable, and the context variable includes tracking identification information;
[0024] Test cases help ensure the quality of software and verify whether its functions meet the requirements by defining test inputs, execution conditions, and preset test results.
[0025] The first test result is the actual test result of the test case.
[0026] Tracing information is a unique identifier used to trace and diagnose requests in a distributed system. Tracing information consists of one or more spans, each of which contains the start time, duration, and related information of a test operation. By using tracing information, developers can more easily locate problems in distributed systems and optimize performance.
[0027] Test operations are specific steps performed in a test case to verify that the software function works as expected. Each operation usually involves user interaction or system behavior. Test cases define a series of test operations to ensure that each part of the system can operate normally and meet functional requirements.
[0028] For example, in a test case of a login function, the operations may include “entering a user name” and “clicking a login button”.
[0029] Elapsed time refers to the time required for an operation to be completed from the start of execution, usually measured in milliseconds or seconds. Elapsed time is used to measure system performance, ensure that response time is within an acceptable range, and help developers identify potential performance issues. Related information of the test operation is used to characterize the status or results of the test operation. It usually includes the following:
[0030] The operation name, which is used to describe the test operation being performed;
[0031] Request parameters, which describe the data passed to the test operation, such as user name and query conditions;
[0032] Return result, which is used to describe the output or status returned by the system after the operation is completed;
[0033] Error information, if the operation fails, is used to record the error type and error description.
[0034] Regarding the composition of the tracing identification information, the tracing identification information can be composed of a 64-bit unique identifier and several span information IDs. The 64-bit unique identifier can be used for tracing, allowing developers to understand the execution path and processing status of the test case associated with the tracing identification information, and to help aggregate the log files associated with the tracing identification information.
[0035] The tracking ID is used to uniquely identify a request, while the span ID records the time and related information of each operation in the request. Operation refers to the specific execution steps of the request. For example, in a login request, the operations include "enter user name", "enter password" and "click the login button".
[0036] Context variables are a collection of external environments that a program needs to run successfully. Therefore, context variables can also be called environments. The environment mainly refers to external variables.
[0037] For example, when a program is running, external variables are needed. Then the external variables need to be input into the program so that the program can be executed correctly. Context switching is the switching of environments.
[0038] Step 120, when the first test result of the target test case does not match the preset test result, determining the tracking identification information in the context variable associated with the target test case; the multiple test cases include the target test case;
[0039] When the first test result of the target test case does not match the preset test result, it means that the target test case has failed to execute. In order to subsequently analyze the cause of the failure of the target test case, it is necessary to collect the first log file corresponding to the target test case. In order to collect the first log file corresponding to the target test case, it is necessary to determine the tracking identification information in the context variable associated with the target test case.
[0040] Step 130 , generating and outputting a first log file corresponding to the target test case according to the tracking identification information, wherein the first log file includes first identification information, and the first identification information includes tracking identification information associated with the target test case.
[0041] According to the tracking identification information, the logs corresponding to the target test cases can be located one by one, and the logs corresponding to the target test cases can be output one by one until the first log file is generated.
[0042] Each test case is independent and can be executed multiple times in different environments and at different times.
[0043] The execution process refers to the actual running of a specific test case, including all operation steps and their results. The same test case can have multiple different execution processes. Due to different test inputs, test environments or test times, each execution process records specific operations and feedback results. Each execution of the same test case can be regarded as an independent event, recording different operations and results.
[0044] Each execution process will generate independent tracking identification information for subsequent tracking and analysis. The tracking identification information is different in different execution processes of the same test case. Exemplarily, the tracking identification information associated with the target test case is watanabe, and one execution process of the target test case corresponds to the first identification information, which may be watanabe-v1, and another execution process of the target test case corresponds to the second identification information, which may be watanabe-v2, and the second identification information also includes the tracking identification information associated with the target test case.
[0045] Therefore, through clear tracking identification information, testers can effectively manage multiple execution processes of the same test case and ensure the accuracy of the test.
[0046] The log output method provided by the embodiment of the present invention obtains the first test result of each test case by executing multiple test cases; one test case is associated with a context variable, and the context variable includes tracking identification information; when the first test result of the target test case does not match the preset test result, the tracking identification information in the context variable associated with the target test case is determined; the multiple test cases include the target test case; here, the tracking identification information associated with the target test case that failed to execute can be determined from a large number of test cases. Finally, the first log file corresponding to the target test case is generated and output according to the tracking identification information, wherein the first log file includes the first identification information, and the first identification information includes the tracking identification information associated with the target test case. Therefore, through the tracking identification information in the context variable, the log used to characterize the execution process of the target test case can be accurately identified from a large number of logs, and the first log file can be output according to the tracking identification information, thereby improving the test efficiency.
[0047] The following describes each step separately:
[0048] In a possible embodiment, before step 110, the method further includes:
[0049] A log appending method is implanted in the framework of the server, wherein the log appending method is used to generate a log file with tracking identification information for the test case.
[0050] A log appending method is embedded in the server framework to generate a log file with tracking identification information for the test case, which facilitates the subsequent rapid location of the first log file of the target test case.
[0051] During the execution of a test case, the log append method can be called when the test case starts to be executed. The log append method combines the test time, test case ID and log message into a formatted string.
[0052] In the actual testing process, when a test case has an exception, the test framework will call the log append method to record the test case ID, the current log message, and the captured exception. This provides clear context variables for subsequent analysis of test results and problem location.
[0053] The log appending method may be: buildLoggingEventAndAppend method.
[0054] In a possible embodiment, step 110 includes:
[0055] The interface of the playback platform is called through the workflow platform, and test parameters are transmitted to the interface of the playback platform to execute the multiple test cases; the test parameters include: test case identifier, environment configuration parameters, playback setting parameters and execution time.
[0056] The execution environment of multiple test cases is a sandbox, which is a network programming virtual execution environment.
[0057] When calling the playback platform interface through the workflow platform to execute multiple test cases, it is usually necessary to transmit some test parameters to the playback platform interface. The test parameters include:
[0058] Test case identifier, which is used to uniquely identify each test case to be executed;
[0059] Environment configuration parameters, which are used to specify the execution environment required for the test case;
[0060] Playback setting parameters, including playback speed, whether to record logs, etc.
[0061] Execution time is used to specify the execution time of the test case. The implementation principle of traffic playback in the playback platform is to use the online portal to record the real traffic of user operations and play it back in the pre-release environment.
[0062] Calling the playback platform's interface through the workflow platform to execute multiple test cases, which may include: using tools or frameworks to record user operation traffic data, which includes the user's interaction with the application, and the requests and responses generated thereby; collating and storing the recorded user operation traffic data, which usually includes the requested URL, request parameters, and HTTP method;
[0063] Import the recorded traffic data of user operations into the pre-launch environment. At this point, the execution environment is similar to the online environment to ensure the effectiveness of the test. When performing playback, the system replays each HTTP request one by one to the pre-launch environment based on the recorded traffic data. These HTTP requests contain all the parameters and settings at the time of recording to ensure the consistency of the test environment. After each HTTP request is sent, the system collects the first test result returned by the pre-launch environment. The system compares the actual first test result returned with the preset test result, and the system will record any inconsistencies or exceptions.
[0064] Because the online traffic of the playback platform is large and the scenarios are comprehensive, it can effectively make up for the limitations of the manual evaluation test scope, thereby reducing the risks brought by rapid business iteration. Figure 2 As shown, the recording and playback platform is used to record test cases and play back test cases; the tested service includes multiple test cases. The recording and playback platform is an automated testing tool used to record user operations and convert the recorded user operations into replayable test cases.
[0065] Recording test cases includes automatically recording all user operations in the application, such as clicking buttons, entering text, selecting drop-down boxes, etc.; and capturing the page status after each operation, such as form data, page elements, etc.; and generating a series of automated test scripts based on the recorded operations for subsequent execution.
[0066] Playing back test cases involves executing the test cases, recording the results of each step during execution, and performing status checks during playback.
[0067] The workflow platform calls the interface of the playback platform to execute multiple test cases in the tested service. The first log file corresponding to the target test case is output according to the tracking identification information and stored in the database. In addition, the user can view the first log file through the recording and playback platform.
[0068] After each test case is executed, the execution results need to be recorded and stored in the database. The execution results include:
[0069] Test case ID, used to identify a specific test case.
[0070] Execution status information, used to indicate whether the test passed, that is, the test succeeded or failed;
[0071] Error information is used to record specific error descriptions when a test fails.
[0072] Execution time, used to record the time when the test case is executed.
[0073] To store the test results, you can create a dedicated database table, such as a test result table, which contains columns such as test case ID, status, error information, and timestamp for subsequent retrieval and analysis.
[0074] After testing all test cases, the database is automatically queried to extract the tracking identification information of all target test cases whose execution status information is "test failed". The step of automatically querying the database can be performed after the test is completed to ensure that the information of the target test cases that failed the test can be quickly obtained.
[0075] In this way, the automatic extraction and log location of failed test cases can be achieved, improving the efficiency and reliability of the test.
[0076] Therefore, by calling the interface of the playback platform through the workflow platform to execute multiple test cases, the risks brought by rapid business iteration can be reduced.
[0077] This involves step 120 .
[0078] All business logs of a single test case can be linked together using the tracking identification information in the context variable.
[0079] According to the tracking identification information, the logs corresponding to the target test cases can be located one by one, and the logs corresponding to the target test cases can be output one by one until the first log file is generated.
[0080] Find the logs that match the trace ID. Specifically, you can create a list to store the qualified logs. When you find the logs that match the trace ID information of the current test case, output the logs that match the trace ID information of the current test case to the console or file one by one. The console output can directly use the log printing function, and the file output can use the file writing function.
[0081] Thus, the logs corresponding to the target test cases can be output one by one and organized into the first log file, which is convenient for saving, consulting and later analysis of the first log file.
[0082] This involves step 130 .
[0083] The first identification information is used to indicate an execution process of the target test case, and the first identification information includes the tracking identification information associated with the target test case. That is, one execution process of the target test case corresponds to the first identification information. Another execution process of the target test case corresponds to the second identification information, and the second identification information also includes the tracking identification information associated with the target test case.
[0084] The user can locate the reason for the failure of the test case execution based on the displayed log file. The reason for the failure of the test case execution may include: failure to view the stack log information, mismatched information in sub-calls, failure of requests and returns in interacting with third parties, etc.
[0085] In a possible embodiment, when a target test case is executed, first identification information is generated, and the first identification information includes tracking identification information related to the target test case and the number of executions of the target test case.
[0086] Exemplarily, the tracking identification information is Haru, Haru is used to refer to a 64-bit character string, the first identification information is Haru1, the first identification information is used to represent that the target test case is executed once, and the second identification information corresponding to another execution process of the target test case is Haru2, and the second identification information is used to represent that the target test case is executed twice.
[0087] Therefore, it is convenient to quickly identify the tracking identification information associated with the target test case and the execution times of the target test case from the first identification information.
[0088] In a possible embodiment, step 130 includes:
[0089] uploading the first log file to an operations support system; and,
[0090] Delete the first log file stored locally.
[0091] Users view the execution log of test cases through the recording and playback platform. The recording and playback platform pulls log files from the operation support system and displays them on the front end by tracking the identification information of the playback test cases.
[0092] Among them, the Operation Support System (OSS) is an integrated, information resource sharing support system for telecom operators. The operation and support system includes the operation and maintenance center and the network management center. It is responsible for the inspection and management of the communication quality and operation of the entire network, and records and collects various data in the operation of the entire network. It has connection lines between all devices in the entire network and performs monitoring and control functions on each device.
[0093] like Figure 3As shown, after the first log file corresponding to the target test case is output according to the tracking identification information, the first log file is uploaded to the OSS.
[0094] The architecture of the log output method includes:
[0095] The platform layer is used to perform playback tasks and present the logs corresponding to the test cases so that users can view the logs corresponding to the test cases.
[0096] The business layer accesses online traffic to record the real traffic of user operations and replay it in the pre-release environment.
[0097] The proxy layer is used to mount and activate the proxy sandbox.
[0098] The service layer is used to perform sub-call playback and upload log files corresponding to test cases.
[0099] The basic layer includes the enhanced framework-specified classes, which are used to save the log files corresponding to the test cases.
[0100] Database layer, including OSS database and MYSQL database.
[0101] Therefore, uploading the first log file to the operation support system and deleting the first log file can reduce the amount of data stored locally, making it easier to stably output the log file later.
[0102] After outputting the first log file corresponding to the target test case according to the tracking identification information, the method further includes:
[0103] Execute the target test case and obtain the second test result;
[0104] When the second test result does not match the preset test result, a second log file corresponding to the target test case is output, wherein the second log file includes second identification information, the second identification information is used to indicate an execution process of the target test case, and the second identification information includes tracking identification information associated with the target test case.
[0105] In a possible embodiment, step 130 includes:
[0106] When a log carrying the tracking identification information is detected, the log carrying the tracking identification information is extracted from a log library; the log library stores the log corresponding to the test case;
[0107] According to the log carrying the tracking identification information, a first log file corresponding to the target test case is generated and output.
[0108] By traversing all logs in the log library and checking whether each log contains tracking identification information, if a log record carries tracking identification information, the log carrying the tracking identification information will be extracted. In this way, log records with tracking identification information can be screened out from the huge log library.
[0109] For the target test case, all logs carrying tracking identification information associated with the target test case are merged in chronological order to obtain a complete first log file corresponding to the target test case. The generated first log file is output to a specified storage location for subsequent use and analysis.
[0110] In this way, logs carrying tracking identification information can be extracted from a massive log library, and a first log file of a target test case is generated based on the logs carrying the tracking identification information, which can provide important data support for subsequent analysis and diagnosis of the target test case.
[0111] In a possible embodiment, step 130 includes:
[0112] Determine the log level of the log corresponding to the target test case;
[0113] When the log level is a preset level, a first log file corresponding to the target test case is output according to the tracking identification information.
[0114] In order to analyze the failed target test cases with high analysis value, it is necessary to identify the logs corresponding to the target test cases and select the log files with analysis value.
[0115] Among them, the target test cases that need to be analyzed can be filtered out from the test cases that failed to execute according to the log level.
[0116] Log level, used to describe the severity of the log error.
[0117] Exemplarily, the preset level is: FATAL; then when the log level of the log corresponding to the target test case is FATAL, the first log file corresponding to the target test case is output according to the tracking identification information.
[0118] The log levels may include: FATAL (fatal error): used to record the most serious errors that cause the application to be unable to continue executing, such as unhandled exceptions, system crashes, etc. Log information usually contains key system status information and exception stack information, etc.
[0119] ERROR: Used to record errors that have occurred, such as files that cannot be opened, data that cannot be read, etc. These errors will not cause the application to crash, but need to be handled by the developer in a timely manner.
[0120] WARN (Warning): Used to record some abnormal situations. These abnormal situations will not cause errors in the application, but need to attract the attention of developers, such as abnormal network connection and parameter transmission errors.
[0121] INFO (Information): Used to record some status information when the application is running normally, such as system startup completion, request processing completion, etc.
[0122] DEBUG: Used to record some status information of the application in debug mode, such as request processing time, request parameters, etc. This information is mainly used to assist developers in debugging and is not suitable for opening in a formal environment.
[0123] TRACE: Usually used to record detailed information such as the call status of each method, the value of each parameter and return value, etc. It is the most detailed log level and is only enabled in special circumstances because it records a large amount of log information.
[0124] Therefore, when the log level is the preset level, outputting the first log file corresponding to the target test case according to the tracking identification information can help developers quickly locate the problem. For log information of different levels, developers can analyze and locate the problem in a targeted manner, so as to solve the problem faster. And it can help eliminate unnecessary log information. By setting the appropriate log level, it is possible to avoid recording too much useless information, thereby saving system resources and improving the performance of the application.
[0125] In summary, in an embodiment of the present invention, by executing multiple test cases, the first test result of each test case is obtained; one test case is associated with a context variable, and the context variable includes tracking identification information; when the first test result of the target test case does not match the preset test result, the tracking identification information in the context variable associated with the target test case is determined; the multiple test cases include the target test case; here, the tracking identification information associated with the target test case that failed to execute can be determined from a large number of test cases. Finally, the first log file corresponding to the target test case is generated and output according to the tracking identification information, wherein the first log file includes the first identification information, and the first identification information includes the tracking identification information associated with the target test case. Therefore, through the tracking identification information in the context variable, the log used to characterize the execution process of the target test case can be accurately identified from a large number of logs, and the first log file can be output according to the tracking identification information, thereby improving the test efficiency.
[0126] Based on the above Figure 1 The log output method shown in the embodiment of the present invention also provides a log output device, such as Figure 4As shown, the log output device 400 may include:
[0127] An execution module 410 is used to execute multiple test cases to obtain a first test result of each test case; one test case is associated with a context variable, and the context variable includes tracking identification information;
[0128] A determination module 420, configured to determine, when the first test result of the target test case does not match the preset test result, the tracking identification information in the context variable associated with the target test case; the multiple test cases include the target test case;
[0129] The output module 430 is used to generate and output a first log file corresponding to the target test case according to the tracking identification information, wherein the first log file includes the first identification information, and the first identification information includes the tracking identification information associated with the target test case.
[0130] In a possible embodiment, the log output device 400 may further include:
[0131] The implantation module is used to implant a log appending method in the framework of the server, wherein the log appending method is used to generate a log file with tracking identification information for the test case.
[0132] In a possible embodiment, the log output device 400 may further include:
[0133] An uploading module, used for uploading the first log file to the operation support system;
[0134] The deleting module is used to delete the first log file stored locally.
[0135] In a possible embodiment, the log output device 400 may further include:
[0136] The generating module is used to generate first identification information when executing a target test case, wherein the first identification information includes tracking identification information related to the target test case and the number of executions of the target test case.
[0137] In a possible embodiment, the output module 430 is specifically configured to:
[0138] Determine the log level of the log corresponding to the target test case;
[0139] When the log level is a preset level, a first log file corresponding to the target test case is output according to the tracking identification information.
[0140] In a possible embodiment, the execution module 410 is specifically configured to:
[0141] The interface of the playback platform is called through the workflow platform, and test parameters are transmitted to the interface of the playback platform to execute multiple test cases; the test parameters include: test case identifier, environment configuration parameters, playback setting parameters and execution time.
[0142] In a possible embodiment, the output module 430 is specifically configured to:
[0143] When a log carrying the tracking identification information is detected, the log carrying the tracking identification information is extracted from a log library; the log library stores the log corresponding to the test case;
[0144] According to the log carrying the tracking identification information, a first log file corresponding to the target test case is generated and output.
[0145] In an embodiment of the present invention, a first test result of each test case is obtained by executing multiple test cases; a test case is associated with a context variable, and the context variable includes tracking identification information; when the first test result of the target test case does not match the preset test result, the tracking identification information in the context variable associated with the target test case is determined; the multiple test cases include the target test case; here, the tracking identification information associated with the target test case that failed to execute can be determined from a large number of test cases. Finally, the first log file corresponding to the target test case is generated and output according to the tracking identification information, wherein the first log file includes the first identification information, and the first identification information includes the tracking identification information associated with the target test case. Therefore, through the tracking identification information in the context variable, the log used to characterize the execution process of the target test case can be accurately identified from a large number of logs, and the first log file can be output according to the tracking identification information, thereby improving the test efficiency.
[0146] The embodiment of the present invention further provides an electronic device, such as Figure 5 As shown, it includes a processor 501, a communication interface 502, a 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.
[0147] Memory 503, used for storing computer programs;
[0148] The processor 501 is used to execute the program stored in the memory 503, and implements the following steps:
[0149] Execute multiple test cases to obtain a first test result of each test case; one test case is associated with a context variable, and the context variable includes tracking identification information;
[0150] In the case where the first test result of the target test case does not match the preset test result, determining the tracking identification information in the context variable associated with the target test case; the multiple test cases include the target test case;
[0151] A first log file corresponding to the target test case is generated and output according to the tracking identification information, wherein the first log file includes first identification information, and the first identification information includes tracking identification information associated with the target test case.
[0152] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0153] The communication interface is used for communication between the above terminal and other devices.
[0154] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0155] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0156] In another embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium stores instructions. When the instructions are executed on a computer, the computer executes the log output method described in any one of the above embodiments.
[0157] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes the log output method described in any one of the above embodiments.
[0158] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0159] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0160] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0161] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A log output method, It is characterized in that Applied to the server, the method includes: Execute multiple test cases to obtain a first test result of each test case; one test case is associated with a context variable, and the context variable includes tracking identification information; In the case where a first test result of a target test case does not match a preset test result, determining tracking identification information in a context variable associated with the target test case; the multiple test cases include the target test case; A first log file corresponding to the target test case is generated and output according to the tracking identification information, wherein the first log file includes the first identification information, and the first identification information includes the tracking identification information associated with the target test case.
2. The method according to claim 1, before executing the plurality of test cases, the method further include: A log appending method is implanted in the framework of the server, wherein the log appending method is used to generate a log file with tracking identification information for a test case.
3. The method according to claim 1, after outputting the first log file corresponding to the target test case according to the tracking identification information, the method further include: uploading the first log file to an operation support system; as well as, Delete the first log file stored locally.
4. The method according to claim 1, further comprising: include: When the target test case is executed, the first identification information is generated, and the first identification information includes tracking identification information related to the target test case and the number of executions of the target test case.
5. The method according to claim 1, wherein the first log file corresponding to the target test case is output according to the tracking identification information, include: Determine the log level of the log corresponding to the target test case; When the log level is a preset level, a first log file corresponding to the target test case is output according to the tracking identification information.
6. The method according to claim 1, wherein the executing multiple test cases, include: Calling the interface of the playback platform through the workflow platform and transmitting test parameters to the interface of the playback platform to execute the multiple test cases; Test parameters include: test case identifier, environment configuration parameters, playback setting parameters and execution time.
7. The method according to claim 1, wherein the first log file corresponding to the target test case is generated and output according to the tracking identification information, include: When a log carrying the tracking identification information is detected, extracting the log carrying the tracking identification information from the log library; The log library stores logs corresponding to the test cases; According to the log carrying the tracking identification information, a first log file corresponding to the target test case is generated and output.
8. A log output device, It is characterized in that The device comprises: An execution module, configured to execute a plurality of test cases and obtain a first test result of each of the test cases; one of the test cases is associated with a context variable, wherein the context variable includes tracking identification information; A determination module, configured to determine, when a first test result of a target test case does not match a preset test result, the tracking identification information in the context variable associated with the target test case; the target test case is included in the plurality of test cases; An output module is used to generate and output a first log file corresponding to the target test case according to the tracking identification information, wherein the first log file includes the first identification information, and the first identification information includes the tracking identification information associated with the target test case.
9. An electronic device, It is characterized in that It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 7 when executing a program stored in a memory.
10. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Log positioning method, system and equipment and storage medium
CN121309330A
System testing method and device, electronic equipment and storage medium
CN121547376A
