Integrated authentication token injection, multi-thread and automatic report generation test method, system and equipment and medium
By combining the multi-threaded Selenium automated testing framework with the Allure framework to achieve automated visual reports, the problems of low efficiency, insufficient resource utilization, and multi-threading conflicts in traditional web automated testing are solved, improving testing efficiency and stability, reducing the cost of result analysis, and enhancing the flexibility and ease of use of the framework.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGXI XINGWANG ZHIYUN TECH CO LTD
- Filing Date
- 2025-12-17
- Publication Date
- 2026-04-17
AI Technical Summary
Traditional web automation testing solutions suffer from low execution efficiency, insufficient resource utilization, multi-threaded resource conflicts, cumbersome report generation, and poor framework scalability, especially in multi-core processor environments.
It adopts the multi-threaded concurrent Selenium automated testing framework, and uses thread-local storage, browser instantiation, headless mode and User-Agent simulation, combined with the Allure framework to realize automated visual reports, decouple business logic from execution logic, and support dynamic configuration of the number of concurrent threads and test files.
It significantly improves testing efficiency and stability, optimizes resource utilization, reduces the cost of results analysis, and enhances the framework's flexibility and ease of use.
Smart Images

Figure CN121880180A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer software automated testing technology, and more specifically, to a method, system, device, and medium for integrated authentication token injection, multi-threading, and automatic report generation testing. Background Technology
[0002] With the accelerating pace of feature iteration in web applications, automated testing, as a crucial element in ensuring software quality, is becoming increasingly important in terms of efficiency and reliability. Traditional web automated testing solutions suffer from the following significant drawbacks: 1. Low execution efficiency: In the traditional single-threaded serial execution mode, test cases run sequentially. When the number of test cases reaches dozens or even hundreds, the total execution time increases linearly. For example, if the average execution time of a single test case is 30 seconds, 100 test cases would take 500 minutes, which is seriously lagging behind the rapid iteration requirements of agile development.
[0003] 2. Insufficient resource utilization: Single-threaded mode can only occupy a single CPU core, resulting in idle hardware resources such as multi-core processors and large amounts of memory. Statistics show that CPU utilization in traditional solutions is typically below 20%, causing a significant waste of hardware resources.
[0004] 3. Multi-threaded resource conflicts: Some testing frameworks attempt to introduce multi-threading, but because the Selenium WebDriver instance does not perform thread isolation, multiple threads share browser resources (such as cookies and LocalStorage), causing test case interference (such as chaotic login status and overlapping operation steps), and significantly reducing test stability.
[0005] 4. Cumbersome report generation and analysis: Traditional test reports are mostly in text or simple HTML format, lacking visual statistics (such as pass rate trends and failure test case distribution), and require manual association of key information such as failure screenshots and logs. Test result analysis takes up more than 30% of the time.
[0006] 5. Poor framework scalability: The test cases are highly coupled with the execution logic. Adding new test modules or adjusting concurrency strategies requires modifying a large amount of underlying code, resulting in high maintenance costs. Summary of the Invention
[0007] The technical problem to be solved by the present invention is to address the above-mentioned shortcomings of the prior art. The purpose of the present invention is to provide an integrated authentication token injection, multi-threading, and automatic report generation testing method. Through multi-threaded resource isolation, automated task scheduling, and integrated visualization reports, an efficient, stable, and easily scalable automated testing framework is constructed.
[0008] The second objective of this invention is to provide a multi-threaded automated testing system.
[0009] The third objective of this invention is to provide a computer device.
[0010] The fourth objective of this invention is to provide a computer storage medium.
[0011] To achieve the first objective mentioned above, this invention provides an integrated authentication token injection, multi-threading, and automatic report generation testing method. Based on the multi-threaded concurrent Selenium automated testing framework, it achieves high cohesion and low coupling to complete the entire automated testing process, specifically including the following steps: Step 1. Configure the basic path, concurrent thread count, and test file list according to user requirements; Step 2. Configure multi-threaded execution, including environment preparation, thread pool management, single-file execution logic, exception handling, and report generation triggering; Step 3. Configure WebDriver management, including thread-local storage, browser instantiation, headless mode, incognito mode, User-Agent emulation, and resource release; Step 4. Write concurrently executable test cases based on the Pytest framework to decouple business logic from automation logic. Specific configurations include pre-processing and post-processing, parameterization and assertions, failure handling and report association, and screenshot path management. Step 5. Implement automated visualization of test results based on the Allure framework, including real-time result collection, HTML report generation, and report access.
[0012] As a further improvement, in step 1, The basic path configuration is as follows: the project root directory is obtained through os.path.dirname(__file__), which unifies the management of resource paths for test files, reports, and screenshots, and avoids cross-environment adaptation issues caused by hard-coded paths; The concurrent thread count is configured as follows: the number of threads is set according to hardware performance to achieve a balance between resources and efficiency; The test file list is configured to store the relative paths of test case files to be executed in a list format, and supports quick addition and deletion of test cases by commenting / uncommenting without modifying the execution logic.
[0013] Furthermore, in step 2, Environment preparation includes: checking and creating a report directory before starting the test to ensure that test results have a unified storage path; copying system environment variables to avoid tool call failures due to missing environment variables; Thread pool management is as follows: a thread pool is created based on concurrent.futures.ThreadPoolExecutor, and the number of concurrent processes is controlled by max_workers=THREAD_COUNT to achieve parallel execution of test files; The single-file execution logic is as follows: A single test file is executed by calling the Pytest command via `subprocess.run()`, with the following parameters: v: Output detailed execution logs; s: Displays printed information for easier debugging; alluredir: Specifies the Allure report data directory for real-time collection of test results; The exception handling is as follows: capture exceptions during the execution of the test file, determine the execution status through result.returncode, and print the error message to ensure that the problem is traceable; The report generation is triggered automatically after all test files have been executed, using the Allure command to generate an HTML report.
[0014] Furthermore, in step 3, Thread-local storage is achieved by creating a thread-private variable `thread_local` using `threading.local()`, ensuring that each thread's WebDriver instance is only visible to itself, thus avoiding conflicts caused by multiple threads sharing resources. Browser instantiation is achieved by initializing a separate Firefox / Chrome browser instance for each thread within the `get_web_driver` method, with custom configuration options supported. Headless mode hides the browser interface, reduces GUI resource consumption, and improves execution speed; Stealth mode disables caching and cookie persistence to ensure a clean testing environment; User-Agent is simulated by setting the browser identifier via set_preference to bypass the detection of automated tools on some websites; Resource release is achieved by destroying the current thread's WebDriver instance using the quit_web_driver method and deleting thread-local variables to prevent memory leaks.
[0015] Furthermore, in step 4, Pre-processing and post-processing include: setup_class: When the test class is initialized, the browser instance of the current thread is obtained through GetDriver.get_web_driver, and the page object is initialized to complete the pre-test preparation; teardown_class: After the test class finishes execution, GetDriver.quit_web_driver is called to release the browser resources of the current thread, ensuring that thread resources are reclaimed in a timely manner; Parameterization and assertions are implemented as follows: test data parameterization is achieved using @pytest.mark.parametrize, supporting multiple input scenarios; business results are verified through assertions. The failure handling and reporting are linked as follows: when an assertion fails, a screenshot is automatically triggered and attached to the Allure report as an attachment via allure.attach.file to facilitate problem localization; Screenshot path management is achieved by generating a screenshot path containing a timestamp using datetime.now().strftime("%m%d%H%M"), ensuring that screenshot files are unique and easy to trace.
[0016] Furthermore, in step 5, Real-time results collection involves Pytest using the alluredir parameter to write data such as test case execution status, execution time, and error stacks to a specified directory during test execution. The HTML report is generated as follows: After all tests are completed, the raw data is converted into an HTML report using the Allure generate command; The generated HTML report can be opened directly in a browser, supporting searching, filtering, and detailed viewing without relying on additional tools.
[0017] Furthermore, the HTML report contains the following key information: Test Overview: Total number of test cases, pass rate, execution time; Use case details: Steps, assertion results, and time taken for each use case; Failure analysis: Error stack traces and related screenshots for failed test cases; Trend statistics: Comparison of historical execution data.
[0018] To achieve the second objective mentioned above, the present invention provides a multi-threaded automated testing system, comprising: The configuration module is used to configure basic paths, concurrent thread counts, and test file lists according to user needs. The multi-threaded execution module is used for configuring multi-threaded execution, including environment preparation, thread pool management, single-file execution logic, exception handling, and report generation triggering. The WebDriver management module is used for WebDriver management and configuration, including thread-local storage, browser instantiation, headless mode, incognito mode, User-Agent emulation, and resource release. The test case module is used to write concurrently executable test cases based on the Pytest framework to decouple business logic from automation logic. Specific configurations include pre-processing and post-processing, parameterization and assertion, failure handling and report association, and screenshot path management. The report generation module is used to automate the visualization of test results based on the Allure framework, including real-time result collection, HTML report generation, and report access.
[0019] To achieve the above-mentioned objective three, the present invention provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the above-mentioned integrated authentication token injection, multi-threading, and automatic report generation testing method.
[0020] To achieve the fourth objective mentioned above, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the aforementioned integrated authentication token injection, multi-threading, and automatic report generation testing method.
[0021] Beneficial effects Compared with the prior art, the advantages of this invention are as follows: 1. Significantly Improved Testing Efficiency: Through multi-threaded concurrent execution, the total test time is approximately inversely proportional to the number of threads. Real-world testing data shows that in an 8-core CPU environment, 10 test files (with a single-threaded total execution time of approximately 30 minutes) are executed concurrently using 4 threads, reducing the total execution time to 8 minutes, representing a 73% efficiency improvement. This is particularly suitable for large-scale regression testing scenarios.
[0022] 2. Significantly Enhanced Test Stability: The WebDriver isolation mechanism based on thread-local storage completely resolves the multi-threaded resource conflict issue. Verified through 100 repeated tests, the concurrent execution test stability (without interference or failure) reached 100%, far exceeding the 65% of the traditional shared Driver mode.
[0023] 3. Resource utilization optimization: The thread pool dynamic scheduling mechanism increases CPU utilization from 15%-20% in traditional single-threaded CPUs to 60%-70%, fully leveraging the performance of multi-core processors and reducing hardware resource waste.
[0024] 4. Reduced cost of results analysis: Allure's visual reports automatically integrate failure screenshots, error stacks, and execution statistics, reducing test results analysis time from 30 minutes per test in the traditional approach to 5 minutes per test, thus reducing labor costs.
[0025] 5. Framework Flexibility and Scalability: The configuration module supports dynamic adjustment of the number of threads and test files without modifying the core code. It supports multiple browsers such as Firefox / Chrome and can be extended to other browsers such as Edge by modifying get_driver.py; test cases and execution logic are decoupled, and adding a new test module only requires writing test case files according to the template, reducing maintenance costs.
[0026] 6. Improved ease of use: Users only need to execute python run_tests.py to start the entire process (concurrent execution + report generation), without having to manually call multiple commands or configure complex parameters, thus lowering the barrier to entry. Attached Figure Description
[0027] Figure 1 This is a flowchart of the present invention. Detailed Implementation
[0028] The present invention will be further described below with reference to specific embodiments shown in the accompanying drawings.
[0029] See Figure 1 A testing method integrating authentication token injection, multithreading, and automatic report generation is characterized by its use of the multithreaded Selenium automated testing framework to achieve a highly cohesive and loosely coupled automated testing process. Specifically, it includes the following steps: Step 1. Configure the basic path, concurrent thread count, and test file list according to user requirements; Step 2. Configure multi-threaded execution, including environment preparation, thread pool management, single-file execution logic, exception handling, and report generation triggering; Step 3. Configure WebDriver management, including thread-local storage, browser instantiation, headless mode, incognito mode, User-Agent emulation, and resource release; Step 4. Write concurrently executable test cases based on the Pytest framework to decouple business logic from automation logic. Specific configurations include pre-processing and post-processing, parameterization and assertions, failure handling and report association, and screenshot path management. Step 5. Implement automated visualization of test results based on the Allure framework, including real-time result collection, HTML report generation, and report access.
[0030] Specifically, step 1 is responsible for centrally managing the core configurations for test execution. In step 1, The basic path configuration is as follows: the project root directory is obtained through os.path.dirname(__file__), which unifies the management of resource paths for test files, reports, and screenshots, and avoids cross-environment adaptation issues caused by hard-coded paths; The concurrent thread count configuration (THREAD_COUNT) is set according to hardware performance (such as the number of CPU cores and memory capacity) (the default value is 2). For example, an 8-core CPU can be configured with 4-6 threads to achieve a balance between resources and efficiency. The test file list (TEST_FILES) is configured to store the relative paths of test case files to be executed in a list format. It supports quickly adding and deleting test cases by commenting / uncommenting them, without requiring modification of the execution logic. For example: TEST_FILES = [ ". / script / web / nongjipingtai / yunyingguankong / yunyingzonglan / test_yunyingzonglan.py", ". / script / web / nongjipingtai / yunyingguankong / yunyinggenzong / test_yunyinggenzong.py", # Test files can be dynamically added or commented out. ] The design of Step 1 enables the framework to have the characteristics of "configuration once, reuse in multiple scenarios", which can adapt to different testing needs without modifying the core code.
[0031] Step 2 serves as the entry point for test execution, responsible for concurrent scheduling of test tasks, result capture, and report triggering. In Step 2, Environment preparation includes: checking and creating the report directory (e.g., . / report / report / report / ) before starting the test to ensure a unified storage path for test results; copying system environment variables (e.g., PATH) to avoid tool call failures due to missing environment variables; Thread pool management is as follows: a thread pool is created based on concurrent.futures.ThreadPoolExecutor, and the number of concurrent processes is controlled by max_workers=THREAD_COUNT to achieve parallel execution of test files; The single-file execution logic is as follows: A single test file is executed by calling the Pytest command via `subprocess.run()`, with the following parameters: v: Output detailed execution logs; s: Displays printed information for easier debugging; alluredir: Specifies the Allure report data directory for real-time collection of test results; example code is as follows: result = subprocess.run( ["pytest", test_file, "-v", "-s", f"--alluredir=. / report / report / report / "], capture_output=True, text=True ) Exception handling involves: capturing exceptions during test file execution (such as path errors or test case crashes), determining the execution status using result.returncode, and printing error messages (such as result.stderr) to ensure that the problem is traceable; Report generation is triggered automatically after all test files have been executed, using the Allure command to generate an HTML report. The command is as follows: subprocess.run( ["allure", "generate", ". / report / report / report / ", "-o", ". / report / report / report / html", "--clean"], env=env, shell=True ) Step 3 addresses the resource isolation issue of Selenium WebDriver in a multi-threaded environment, ensuring that each thread uses a browser instance independently. In step 3, Thread Local Storage is achieved by creating a thread-private variable `thread_local` using `threading.local()`, ensuring that each thread's WebDriver instance is only visible to itself, thus avoiding conflicts caused by multiple threads sharing resources (such as cross-referencing cookies or overlapping operation steps). Browser instantiation is achieved by initializing a separate Firefox / Chrome browser instance for each thread within the `get_web_driver` method, with custom configuration options supported. Headless mode hides the browser interface, reduces GUI resource consumption, and improves execution speed. Incognito mode disables caching and cookie persistence to ensure a clean testing environment. User-Agent is simulated by setting the browser identifier via set_preference to bypass the detection of automated tools on some websites; Resource release involves destroying the current thread's WebDriver instance using the `quit_web_driver` method and deleting thread-local variables to prevent memory leaks. Example code is as follows: @classmethod def quit_web_driver(cls): if hasattr(thread_local, "web_driver"): thread_local.web_driver.quit() del thread_local.web_driver # Remove thread-private variable In step 4, Pre-processing and post-processing include: setup_class: When the test class is initialized, the browser instance of the current thread is obtained through GetDriver.get_web_driver, and the page object (such as PageYunyingzonglan) is initialized to complete the pre-test preparation (such as page navigation and element positioning). teardown_class: After the test class finishes execution, GetDriver.quit_web_driver is called to release the browser resources of the current thread, ensuring that thread resources are reclaimed in a timely manner; Parameterization and assertions are implemented as follows: Test data parameterization is achieved using `@pytest.mark.parametrize`, supporting multiple input scenarios; assertions are used to verify business results (such as the existence of page elements, data correctness); for example: @pytest.mark.parametrize("path", [get_path_yunyingzonglan_chaxun_strftime()]) def test_chaxun(self, path): self.Yunyingzonglan.page_chaxun() # Perform the query operation assert 'Total working area (mu)' == self.Yunyingzonglan.page_get_list_zhibiao_value() # Verification result Failure handling and reporting are linked as follows: When an assertion fails, a screenshot is automatically taken (using the `base_get_image` method), and the screenshot is attached as an attachment to the Allure report via `allure.attach.file` for easier problem localization; for example: except Exception as e: self.Yunyingzonglan.base_get_image(path) # Save screenshot allure.attach.file(path, name="Screenshot of assertion failure", attachment_type=allure.attachment_type.PNG) # Related report raise# Keep the test in a failed state Screenshot path management is achieved by generating a screenshot path containing a timestamp (e.g., . / image / error_yunyingzonglan_chaxun_08151430.png) using datetime.now().strftime("%m%d%H%M"), ensuring that the screenshot file is unique and easy to trace.
[0032] In step 5, Real-time results collection is as follows: During test execution, Pytest uses the alluredir parameter to write data such as test case execution status (success / failure), time consumption, and error stack to a specified directory (e.g., . / report / report / report / ). The generated HTML report is as follows: After all tests are completed, the raw data is converted into an HTML report using the Allure generate command; it contains the following key information: Test Overview: Total number of test cases, pass rate, execution time; Use case details: Steps, assertion results, and time taken for each use case; Failure analysis: Error stack traces and related screenshots for failed test cases; Trend Statistics: Comparison of Historical Execution Data The generated HTML report can be opened directly in a browser (e.g., . / report / report / report / html / index.html), supporting searching, filtering, and detailed viewing without relying on additional tools.
[0033] A multi-threaded automated testing system is proposed. Based on the multi-threaded concurrent Selenium automated testing framework, the system achieves high cohesion and low coupling through modular design, enabling each module to work collaboratively to complete the entire automated testing process. The modules include: The configuration module (config.py) is used to configure basic paths, concurrent thread counts, and test file lists according to user needs. The multi-threaded execution module (run_tests.py) is used for multi-threaded execution configuration, including environment preparation, thread pool management, single-file execution logic, exception handling, and report generation triggering. The WebDriver management module (get_driver.py) is used for WebDriver management configuration, including thread-local storage, browser instantiation, headless mode, incognito mode, User-Agent emulation, and resource release. The test case module (test_yunyinggenzong.py) is used to write concurrently executable test cases based on the Pytest framework to decouple business logic from automation logic. Specific configurations include pre-processing and post-processing, parameterization and assertions, failure handling and report association, and screenshot path management. The report generation module is used to automate the visualization of test results based on the Allure framework, including real-time result collection, HTML report generation, and report access.
[0034] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the aforementioned integrated authentication token injection, multi-threading, and automatic report generation testing method.
[0035] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the aforementioned integrated authentication token injection, multi-threading, and automatic report generation testing method.
[0036] Practical Applications In practical applications, it can be divided into 5 stages, all without human intervention: 6.1 Configuration Phase Users can define concurrency strategies and test scope by modifying THREAD_COUNT (e.g., setting it to 4) and TEST_FILES (e.g., adding 5 test file paths) in config.py.
[0037] 6.2 Initialization Phase Run `python run_tests.py` to start the test. The framework will automatically check and create the report directory, copy the system environment variables, and initialize the thread pool (the maximum number of threads is THREAD_COUNT).
[0038] 6.3 Concurrent Execution Phase The thread pool allocates multiple threads, and each thread performs the following operations independently: Call GetDriver.get_web_driver to obtain a dedicated browser instance, configure headless / incognito mode, and inject the authentication token; Execute the test files specified in TEST_FILES and run the test case steps (such as page operations and assertions) through Pytest. If a test case fails, a screenshot will be automatically taken and associated with the Allure report data directory.
[0039] 6.4 Resource Recovery Stage After a single test file is executed, the thread calls GetDriver.quit_web_driver via teardown_class to destroy the browser instance and release thread resources.
[0040] 6.5 Report Generation Phase After all threads have finished executing, the framework calls the Allure command to convert the raw results into an HTML report, which users can then view directly through a browser.
[0041] This invention implements thread-level isolation for the WebDriver based on thread-local variables (threading.local()), ensuring that multiple concurrently executed test cases have independent browser instances, avoiding test state pollution (such as test case interference caused by cookie and session sharing). Simultaneously, it improves testing efficiency by controlling the concurrency level through a thread pool (ThreadPoolExecutor). It supports injecting authentication tokens via sessionStorage, skipping the manual login process and improving pre-test efficiency. The test file list (TEST_FILES) and the number of concurrent threads (THREAD_COUNT) are centrally managed through config.py, supporting dynamic adjustment of the test scope and execution efficiency, adapting to different test scenarios without modifying the core code.
[0042] The above are merely preferred embodiments of the present invention. It should be noted that those skilled in the art can make several modifications and improvements without departing from the structure of the present invention, and these will not affect the effectiveness of the implementation of the present invention or the practicality of the patent.
Claims
1. A testing method integrating authentication token injection, multi-threading, and automatic report generation, characterized in that, Based on the multi-threaded concurrent Selenium automated testing framework, this system achieves a highly cohesive and loosely coupled automated testing process, specifically including the following steps: Step 1. Configure the basic path, concurrent thread count, and test file list according to user requirements; Step 2. Configure multi-threaded execution, including environment preparation, thread pool management, single-file execution logic, exception handling, and report generation triggering; Step 3. Configure WebDriver management, including thread-local storage, browser instantiation, headless mode, incognito mode, User-Agent emulation, and resource release; Step 4. Write concurrently executable test cases based on the Pytest framework to decouple business logic from automation logic. Specific configurations include pre-processing and post-processing, parameterization and assertions, failure handling and report association, and screenshot path management. Step 5. Implement automated visualization of test results based on the Allure framework, including real-time result collection, HTML report generation, and report access.
2. The integrated authentication token injection, multi-threading, and automatic report generation testing method according to claim 1, characterized in that, In step 1, The basic path configuration is as follows: the project root directory is obtained through os.path.dirname(__file__), which unifies the management of resource paths for test files, reports, and screenshots, and avoids cross-environment adaptation issues caused by hard-coded paths; The concurrent thread count is configured as follows: the number of threads is set according to hardware performance to achieve a balance between resources and efficiency; The test file list is configured to store the relative paths of test case files to be executed in a list format, and supports quick addition and deletion of test cases by commenting / uncommenting without modifying the execution logic.
3. The integrated authentication token injection, multi-threading, and automatic report generation testing method according to claim 1, characterized in that, In step 2, Environment preparation includes: checking and creating a report directory before starting the test to ensure that test results have a unified storage path; copying system environment variables to avoid tool call failures due to missing environment variables; Thread pool management is as follows: a thread pool is created based on concurrent.futures.ThreadPoolExecutor, and the number of concurrent processes is controlled by max_workers=THREAD_COUNT to achieve parallel execution of test files; The single-file execution logic is as follows: A single test file is executed by calling the Pytest command via `subprocess.run()`, with the following parameters: v: Output detailed execution logs; s: Displays printed information for easier debugging; alluredir: Specifies the Allure report data directory for real-time collection of test results; The exception handling is as follows: capture exceptions during the execution of the test file, determine the execution status through result.returncode, and print the error message to ensure that the problem is traceable; The report generation is triggered automatically after all test files have been executed, using the Allure command to generate an HTML report.
4. The integrated authentication token injection, multi-threading, and automatic report generation testing method according to claim 1, characterized in that, In step 3, Thread-local storage is achieved by creating a thread-private variable `thread_local` using `threading.local()`, ensuring that each thread's WebDriver instance is only visible to itself, thus avoiding conflicts caused by multiple threads sharing resources. Browser instantiation is achieved by initializing a separate Firefox / Chrome browser instance for each thread within the `get_web_driver` method, with custom configuration options supported. Headless mode hides the browser interface, reduces GUI resource consumption, and improves execution speed; Stealth mode disables caching and cookie persistence to ensure a clean testing environment; User-Agent is simulated by setting the browser identifier via set_preference to bypass the detection of automated tools on some websites; Resource release is achieved by destroying the current thread's WebDriver instance using the quit_web_driver method and deleting thread-local variables to prevent memory leaks.
5. The integrated authentication token injection, multi-threading, and automatic report generation testing method according to claim 1, characterized in that, In step 4, Pre-processing and post-processing include: setup_class: When the test class is initialized, the browser instance of the current thread is obtained through GetDriver.get_web_driver, and the page object is initialized to complete the pre-test preparation; teardown_class: After the test class finishes execution, GetDriver.quit_web_driver is called to release the browser resources of the current thread, ensuring that thread resources are reclaimed in a timely manner; Parameterization and assertions are implemented as follows: test data parameterization is achieved using @pytest.mark.parametrize, supporting multiple input scenarios; business results are verified through assertions. The failure handling and reporting are linked as follows: when an assertion fails, a screenshot is automatically triggered and attached to the Allure report as an attachment via allure.attach.file to facilitate problem localization; Screenshot path management is achieved by generating a screenshot path containing a timestamp using datetime.now().strftime("%m%d%H%M"), ensuring that screenshot files are unique and easy to trace.
6. The integrated authentication token injection, multi-threading, and automatic report generation testing method according to claim 1, characterized in that, In step 5, Real-time results collection involves Pytest using the alluredir parameter to write data such as test case execution status, execution time, and error stacks to a specified directory during test execution. The HTML report is generated as follows: After all tests are completed, the raw data is converted into an HTML report using the Allure generate command; The generated HTML report can be opened directly in a browser, supporting searching, filtering, and detailed viewing without relying on additional tools.
7. The integrated authentication token injection, multi-threading, and automatic report generation testing method according to claim 6, characterized in that, The HTML report contains the following key information: Test Overview: Total number of test cases, pass rate, execution time; Use case details: Steps, assertion results, and time taken for each use case; Failure analysis: Error stack traces and related screenshots for failed test cases; Trend statistics: Comparison of historical execution data.
8. A multi-threaded automated testing system, characterized in that, include: The configuration module is used to configure basic paths, concurrent thread counts, and test file lists according to user needs. The multi-threaded execution module is used for configuring multi-threaded execution, including environment preparation, thread pool management, single-file execution logic, exception handling, and report generation triggering. The WebDriver management module is used for WebDriver management and configuration, including thread-local storage, browser instantiation, headless mode, incognito mode, User-Agent emulation, and resource release. The test case module is used to write concurrently executable test cases based on the Pytest framework to decouple business logic from automation logic. Specific configurations include pre-processing and post-processing, parameterization and assertion, failure handling and report association, and screenshot path management. The report generation module is used to automate the visualization of test results based on the Allure framework, including real-time result collection, HTML report generation, and report access.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the integrated authentication token injection, multi-threading, and automatic report generation testing method according to any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the integrated authentication token injection, multi-threading, and automatic report generation test method according to any one of claims 1-7.