Table of contents
About the design of login test cases
Test development strategy and process
Integration testing: Selenium + JUnit
Design and implementation of test cases
Use case one: successful login test
Use case 2: Login failure test
Use case three: Test whether you can chat
Use case four: Test deletion of chat history
Use case five: Test search users
Use Case 6: Test deleting friends
Use Case 7: Test adding friends
introduction:
In software development, test development plays a vital role. It not only improves testing efficiency, but also ensures the stability and reliability of the project. This blog will delve into the test development strategies and automation techniques I applied in the "WeTalk" web chat room project, and their impact on project quality.
Test development goals:
- Design reliable automated test cases to cover the core functions of the project and different scenarios.
- Improve testing efficiency, reduce manual testing workload, and accelerate project delivery.
- Ensure continuous integration and continuous delivery processes to ensure that each code submission is fully tested.
"WeTalk" project background
"WeTalk" is a modern web chat room application that provides users with a convenient communication platform, making communication between people closer. The goal is to create a stable, efficient, user-friendly chat platform, which requires adequate test coverage and quality assurance.
For details about the WeTalk project, please see my last blog: Project Introduction: "WeTalk" web chat room - a wonderful fusion of Spring Boot, MyBatis, MySQL and WebSocket_Humble Jingnan Mango's Blog-CSDN Blog
About the design of login test cases
I design it by guessing the problems I may encounter from the aspects of function, interface, compatibility, ease of use, security, network, etc.
Test development strategy and process
In the "WeTalk" project, we adopted a series of test development strategies and processes to ensure the quality of the project. First, we start considering the design of test cases from the requirements analysis stage and clarify the expected behavior of each function point. Then, we used the automated testing framework to build a comprehensive automated testing system for integration testing. These automated test cases cover the core functions of the project, as well as testing situations in different scenarios.
Integration testing: Selenium + JUnit
In order to verify whether the various modules of the "WeTalk" project work together when integrated, I chose Selenium as the automated testing tool and combined it with JUnit to write integration test cases. By simulating user actions, I was able to automatically test the functionality, interactions, and integration between different modules of the user interface. For example, for the login function, I wrote a Selenium script to simulate the user entering the user name and password, then verify whether the login is successful, and check whether the user can correctly jump to the main interface.
Integration testing not only helped me discover interaction issues between multiple modules, but also ensured the overall stability of the system. The powerful functions of Selenium allow me to simulate various user scenarios and verify the performance of the system under different circumstances, thus providing a solid guarantee for the quality of the project.
Interface testing: Postman
In addition to integration testing, I also used the Postman tool for interface testing. For functions such as login, I use Postman to send a login request and verify that the returned status code, response data, and related fields are as expected.
The advantage of using Postman for interface testing is that it can help me quickly test different APIs, saving a lot of manual testing time, and it can also perform data verification to ensure the accuracy and completeness of the data.
Design and implementation of test cases
I designed a series of test cases for unit testing based on the functionality of each module. For example, for the user login function, I wrote test cases to verify whether the user can log in successfully when entering the correct user name and password, and whether the user can be correctly prompted when entering the wrong user name and password. For the message sending function, I tested whether the message can be correctly delivered to the recipient and displayed on the interface. Through these test cases, we can ensure the normal operation of the basic functions of each module.
Automated test demonstration:
Code written based on selenium3 and Junit5
Use case one: successful login test
Enter the correct username and password, expected result: successful login
Test result: passed
Use case 2: Login failure test
Enter incorrect username and password, expected result: login failed
Test result: passed
Use case three: Test whether you can chat
Next, let’s test whether two users can send messages to each other. Since my WeTalk uses the same cookie name to store session information when logging in, the browser may regard them as the same cookie and only one can be maintained. The user's login status. So we have to turn on incognito mode to log in two users with one browser
Test if a user sends a message and another user can receive it immediately. Expected result: Can receive messages from other users immediately.
Test result: passed
Use case four: Test deletion of chat history
Test deletion of chat history, expected result: chat history is deleted
Test result: passed
Use case five: Test search users
Test whether the user can be searched. Expected result: the user is searched.
Test result: passed
Use Case 6: Test deleting friends
Test deletion of friends, expected results: friends are deleted and chat history with friends disappears
Test result: passed
Use Case 7: Test adding friends
Test whether friends can be added. Expected results: The user sends a friend application and another user accepts the application.
Test result: passed
Conclusion:
In the "WeTalk" project, I carefully built a test development system, integrated Selenium and JUnit for integration testing, and used Postman to implement interface testing. By designing test cases for each module, I verified core functionality such as login functionality, messaging, etc. This not only helps detect problems early and improves testing efficiency, but also ensures system stability. Test development plays a vital role in modern software development, providing solid support for successful project delivery. Looking to the future, test development will continue to be closely integrated with technological innovation, contributing to the continuous improvement of software quality and user experience.