当前位置: 首页 > news >正文

网页五子棋测试报告

目录

1.项目概述

1.1 项目背景

1.2 核心技术

1.3 业务功能模块

1.4 测试环境

2.测试用例

2.1 用户模块

2.2 匹配模块

2.3 对战模块

3.手动测试

3.1 用户模块

3.1.1 注册功能

3.1.2 登录功能

3.2 匹配模块

3.3 对战模块

4.自动化测试

4.1 自动化环境

4.2 注册页面

4.3 登录页面

4.4 匹配页面


1.项目概述

1.1 项目背景

WebSocket 是 HTML5 引入的一种通信机制,它允许网页与服务器之间建立持久连接,实现双向实时消息推送。与传统 HTTP 的“请求-响应”模式不同,WebSocket 一旦握手成功,双方即可随时主动发送数据,无需客户端反复轮询。

在传统 Web 架构中,服务器只能被动响应客户端的请求,无法主动推送信息。对于像五子棋对战或即时聊天这类需要高频交互的应用,若依赖 HTTP 轮询,不仅延迟高、资源消耗大,还难以保证消息的及时性。而 WebSocket 基于 TCP 协议,连接建立后通信效率接近原生 Socket,极大提升了实时应用的体验。

1.2 核心技术

  • Spring/SpringBoot/SpringMVC
  • WebSocket
  • MySQL
  • MyBatis
  • HTML/CSS/JS/AJAX

1.3 业务功能模块

用户模块:用户注册,用户登录,用户天梯分数记录,用户比赛场次记录

匹配模块:按照用户的天梯分数实现匹配机制

对战模块:实现两个玩家在网页端进行五子棋对战的功能

1.4 测试环境

操作系统:Windows 11(64位)

浏览器:Edge (版本:149.0.4022.98)

2.测试用例

2.1 用户模块

2.2 匹配模块

2.3 对战模块

3.手动测试

3.1 用户模块

3.1.1 注册功能

成功注册流程:

输入不存在的用户名,输入一个随机密码,点击提交

结果:提示注册成功,随后跳转到登录页面

异常注册流程:

(1)用户名和密码都为空,点击提交

结果:提示注册失败

(2)输入一个数据库中已存在的用户名,输入密码,点击提交按钮

结果:提示注册失败

3.1.2 登录功能

成功登录流程:

输入已注册过的用户名和密码,点击提交按钮

结果:提示登录成功

确认弹框后来到游戏大厅页面

异常登录流程:

(1)不输入用户名和密码,点击提交按钮

结果:提示登录失败

(2)输入已注册的用户名,但输入错误的密码

结果:提示登录失败

3.2 匹配模块

(1)匹配逻辑测试

来到游戏大厅页面,点击开始匹配

结果:按钮文字由“开始匹配”变为“匹配中...(点击停止)

再点击按钮

结果:按钮文字重新变回“开始匹配”

(2)成功匹配测试

此时玩家张三和玩家李四都点击开始匹配

结果:两个玩家都来到游戏房间页面

多开测试:

用两个不同的浏览器页面登录同一玩家张三

结果:提示后登录的那一个页面“检测到多开!”

3.3 对战模块

落子与回合逻辑:

此时玩家张三为先手,张三在棋盘上随机点击一个位置落子

落子后在棋盘上绘制出一个棋子,同时下方文字变成“轮到对方落子了!”

接着是玩家李四的落子

李四落子后,页面又绘制出一个棋子,同时下方文字变成“轮到对方落子了!”

成功判定:

当玩家形成五子连珠的情况时(右对角线),就判定这个玩家获胜,下方文字为“你赢了”,并且多出一个“回到大厅”按钮

同时,对手下方的文字为“你输了”

五子连珠还有其他几种情况

(1)横向

(2)竖向

(3)左对角线

异常情况:

当玩家张三在游戏进行中时退出页面,或者关闭浏览器

结果:玩家李四直接显示“你赢了”,此时并未形成五子连珠

4.自动化测试

4.1 自动化环境

Java + idea + selenium + webdrivermanager(驱动管理)+ Edge浏览器

4.2 注册页面

package tests; import common.Utils; import org.openqa.selenium.Alert; import org.openqa.selenium.By; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import java.io.IOException; public class RegisterPage { private Utils utils; private WebDriverWait wait; public RegisterPage(Utils utils) { this.utils = utils; this.wait = utils.getWait(); } /** * 注册框检查 */ public void checkPage() throws IOException { utils.getDriver().findElement(By.cssSelector("#username")); utils.getDriver().findElement(By.cssSelector("#password")); utils.getDriver().findElement(By.cssSelector("#submit")); utils.screenShot(Thread.currentThread().getStackTrace()[1].getMethodName()); } /** * 成功注册流程 */ public void registerSuc(String username, String password) { utils.getDriver().findElement(By.cssSelector("#username")).clear(); utils.getDriver().findElement(By.cssSelector("#password")).clear(); utils.getDriver().findElement(By.cssSelector("#username")).sendKeys(username); utils.getDriver().findElement(By.cssSelector("#password")).sendKeys(password); utils.getDriver().findElement(By.cssSelector("#submit")).click(); wait.until(ExpectedConditions.alertIsPresent()); Alert alert = utils.getDriver().switchTo().alert(); alert.accept(); } /** * 失败注册流程 * 用户名不填写 */ public void registerFail(String password) { utils.getDriver().findElement(By.cssSelector("#username")).clear(); utils.getDriver().findElement(By.cssSelector("#password")).clear(); // 只填密码,不填用户名 utils.getDriver().findElement(By.cssSelector("#password")).sendKeys(password); utils.getDriver().findElement(By.cssSelector("#submit")).click(); wait.until(ExpectedConditions.alertIsPresent()); Alert alert = utils.getDriver().switchTo().alert(); alert.accept(); } /** * 等待跳转到登录页面 */ public boolean waitForRedirectToLogin() { try { return wait.until(driver -> driver.getCurrentUrl().contains("login.html") ); } catch (Exception e) { return false; } } public void quit() { utils.quit(); } }

4.3 登录页面

package tests; import common.Utils; import org.openqa.selenium.Alert; import org.openqa.selenium.By; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import java.io.IOException; public class LoginPage { private Utils utils; private WebDriverWait wait; public LoginPage(Utils utils) { this.utils = utils; this.wait = utils.getWait(); } /** * 登录框检查 * @throws IOException */ public void checkPage() throws IOException { // 通过 utils.getDriver() 获取当前浏览器的驱动 utils.getDriver().findElement(By.cssSelector("#username")); utils.getDriver().findElement(By.cssSelector("#password")); utils.getDriver().findElement(By.cssSelector("#submit")); // 截图 utils.screenShot(Thread.currentThread().getStackTrace()[1].getMethodName()); } /** * 成功登录流程 * @param username 用户名 * @param password 密码 */ public void loginSuc(String username, String password) { utils.getDriver().findElement(By.cssSelector("#username")).clear(); utils.getDriver().findElement(By.cssSelector("#password")).clear(); utils.getDriver().findElement(By.cssSelector("#username")).sendKeys(username); utils.getDriver().findElement(By.cssSelector("#password")).sendKeys(password); utils.getDriver().findElement(By.cssSelector("#submit")).click(); // 等待弹窗出现并点击确认 wait.until(ExpectedConditions.alertIsPresent()); Alert alert = utils.getDriver().switchTo().alert(); alert.accept(); } /** * 失败登录流程 * 密码错误 */ public void loginFail(String username, String wrongPassword) { utils.getDriver().findElement(By.cssSelector("#username")).clear(); utils.getDriver().findElement(By.cssSelector("#password")).clear(); utils.getDriver().findElement(By.cssSelector("#username")).sendKeys(username); utils.getDriver().findElement(By.cssSelector("#password")).sendKeys(wrongPassword); utils.getDriver().findElement(By.cssSelector("#submit")).click(); wait.until(ExpectedConditions.alertIsPresent()); Alert alert = utils.getDriver().switchTo().alert(); alert.accept(); } /** * 等待跳转到游戏大厅 * @return true表示跳转成功 */ public boolean waitForRedirectToGameHall() { try { return wait.until(driver -> driver.getCurrentUrl().contains("game_hall.html") ); } catch (Exception e) { return false; } } /** * 判断是否还在登录页面 */ public boolean isOnLoginPage() { return utils.getDriver().getCurrentUrl().contains("login.html"); } /** * 关闭当前浏览器 */ public void quit() { utils.quit(); } }

4.4 匹配页面

package tests; import common.Utils; import org.openqa.selenium.By; public class GameHallPage { private Utils utils; public GameHallPage(Utils utils) { this.utils = utils; } public String getUserInfo() { return utils.getDriver().findElement(By.id("screen")).getText(); } public void clickMatchButton() { utils.getDriver().findElement(By.id("match-button")).click(); } public void startMatch() { String btnText = utils.getDriver().findElement(By.id("match-button")).getText(); if ("开始匹配".equals(btnText)) { clickMatchButton(); } } public void waitForRedirectToGameRoom() { utils.getWait().until(driver -> driver.getCurrentUrl().contains("game_room.html") ); } }

执行测试:

import common.Utils; import tests.GameHallPage; import tests.LoginPage; public class RunTest { public static void main(String[] args) { // 浏览器1:普通模式 Utils utils1 = new Utils("http://127.0.0.1:8080/login.html", false); LoginPage login1 = new LoginPage(utils1); login1.loginSuc("zhangsan", "123"); GameHallPage gameHallPage = new GameHallPage(utils1); gameHallPage.startMatch(); // 浏览器2:无痕模式 Utils utils2 = new Utils("http://127.0.0.1:8080/login.html", true); LoginPage login2 = new LoginPage(utils2); login2.loginSuc("lisi", "123"); GameHallPage gameHallPage2 = new GameHallPage(utils2); gameHallPage2.startMatch(); } }
http://www.jsqmd.com/news/1175446/

相关文章:

  • 官方发布 2026 万国腕表维修避坑指南,各城市售后中心最新地址汇总 - 万国维修售后服务中心
  • 2026 七月万国手表保养维修全攻略,北上广深售后中心最新地址 - 万国维修售后服务中心
  • TED演讲英语学习法:快速提升听力口语的终极指南
  • 专业的智能体算力架构高性价比品牌公司
  • 技术需求优先级排序:从直觉判断到多因子评分模型的工程化升级
  • go2_ros2_sdk部署指南:在Docker中快速搭建Unitree GO2的ROS2开发环境
  • HR转型怎么走?招聘、培训和组织发展方向不一样
  • 2026筑宅安,邢台本地靠谱阳台渗水维修团队 - 筑宅安
  • PrimoToon自定义扩展指南:如何添加新的材质类型与特效
  • 2026重庆企业品牌升级选型指南|权威调研拆解6家川渝咨询机构实力,落地避坑六大要点全梳理 - 互联网科技品牌测评
  • 把 Cursor 变成 AI 创作工作站:接入 Ace Data Cloud MCP 的完整指南
  • 济南莱芜钢城闲置奢侈品手表邮寄回收流程,奢二网保价包邮 - 讯息早知道
  • AI搜索品牌曝光监控:多模型API采集实现
  • 2026冰块厂家排行榜:贵阳工业降温冰块哪家强?实测推荐 - 热点咨讯
  • 2026年7月最新武汉浪琴官方售后客户服务热线与维修网点地址汇总 - 浪琴服务中心
  • 如何在Android设备上运行桌面级Minecraft:PojavLauncher终极指南
  • 如何快速实现语音转文字:AsrTools免费开源工具的完整指南
  • Linux网络命名空间深度解析:理解容器网络隔离的底层实现与iptables/netfilter交互机制
  • qmqtt实战案例:构建发布-订阅模式的Qt物联网应用
  • 2026上海普陀区黄金回收店最新榜单:环球港到真如,实测前3名 - 上海宝易埠珠宝公司
  • 2026 年徐州黄金回收线下全流程实测,本地实体门店交易全过程记录与完整避坑指南 - 钦扬网络
  • 3步解决私有知识库管理难题:Langchain-Chatchat本地智能问答系统实战指南
  • 如何高效构建虚拟世界:Arnis地理数据转换引擎深度解析
  • Flutter PullToRefresh终极指南:NestedScrollView复杂滚动场景的完整解决方案
  • VSCode 1.90 Git 状态栏消失:3 种场景排查与 settings.json 配置修复
  • 完全指南:5分钟开启免费开源三国杀网页版
  • Gitee 源码部署实战:SpringBoot+Vue 项目 5 步本地启动与 404 错误排查
  • FxSound终极音频调校指南:3步打造你的专属声音世界
  • 2026 年 7 月常德黄金回收乱象曝光!流动人员偷秤压价频发,三区 6 家正规实体门店大盘价完整公示 - 不晚生活号
  • Qwen3.5-397B-A17B-NVFP4推理加速技巧:PyTorch 2.10与Transformers 5.2.0优化组合