【项目日记(五)】搜索引擎-测试报告

❣博主主页: 33的博客

▶️文章专栏分类:项目日记◀️

🚚我的代码仓库: 33的代码仓库🚚

🫵🫵🫵关注我带你了解更多项目内容

这里写目录标题

1.项目背景

搜索引擎主要采用了前后端分离的方式来实现,把整个项目分成前端模块,索引模块,搜索模块,同时将其布置到云服务器中。该搜索引擎只是基于java API的站内搜索,根据用户输入的关键词按权重检索出对应的结果。

2.测试环境

软件:Google Chrome

开发工具:IDEA

测试工具:自动化测试工具Selenium

操作系统:Windows 10家庭中文版

浏览器版本:Google Chrome126.0.6478.115(正式版本) (64 位)

3.测试计划

测试用例:

3.1功能测试

执行过程部分截图:



3.2自动化测试

java 复制代码
package docsearcher;

import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.openqa.selenium.By;

import static java.lang.Thread.sleep;

public class docSearcher extends InitAndEnd{
    @Order(1)
    @Test
    public void search() throws InterruptedException {
        webDriver.get("http://119.91.235.248:8080/index.html");
        sleep(3000);
        webDriver.findElement(By.cssSelector("body > div > div.header > input[type=text]")).sendKeys("array");
        sleep(3000);
        webDriver.findElement(By.cssSelector("#search-btn")).click();
        sleep(3000);
        String s=webDriver.findElement(By.cssSelector("body > div > div.result > div.count")).getText();
        StringBuilder ret=new StringBuilder();
        for (char c:s.toCharArray()){
            if(Character.isDigit(c)){
                ret.append(c);
            }
        }
        if(ret.equals("0")){
            System.out.println("测试失败");
        }else {
            System.out.println("测试通过");
        }
    }
    @Order(2)
    @Test
    public void search2() throws InterruptedException {
        webDriver.get("http://119.91.235.248:8080/index.html");
        sleep(3000);
        webDriver.findElement(By.cssSelector("body > div > div.header > input[type=text]")).clear();
        webDriver.findElement(By.cssSelector("body > div > div.header > input[type=text]")).sendKeys(" ");
        sleep(3000);
        webDriver.findElement(By.cssSelector("#search-btn")).click();
        sleep(3000);
        String s=webDriver.findElement(By.cssSelector("body > div > div.result > div.count")).getText();
        StringBuilder ret=new StringBuilder();
        for (char c:s.toCharArray()){
            if(Character.isDigit(c)){
                ret.append(c);
            }
        }
        System.out.println(ret);
        String SS=ret.toString();
        if(SS.equals("0")){
            System.out.println("测试通过");
        }
    }
}

亮点:

使用Selenium与Junit结合来测试:

①使用了JUnit5中提供的注解:避免生成过多的对象,造成资源和时间的浪费,提高了自动化的执行

效率。

②只创建一次驱动对象,避免每 个用例重复创建驱动对象造成时间和资源的浪费。

③使用参数化:保持用例的简洁,提高代码的可读性

④使用测试套件:降低了测试人员的工作量,通过套件一次执行所有要运行的测试用例。

⑤使用了等待:提高了自动化的运行效率,提高了自动化的稳定性,减小误报的可能性。

⑥使用了屏幕截图:方便问题的追溯以及问题的解决

相关推荐
熊文豪9 小时前
给国产数据库装上中文搜索引擎:zhparser vs jieba 分词实战,与三个隐藏关卡
数据库·搜索引擎·电科金仓
MartinYeung510 小时前
[论文学习]Unsafe LLM-Based Search: AI搜索引擎安全风险的定量分析与缓解
人工智能·学习·搜索引擎
IT新视界1 天前
Elasticsearch信创国产化替代
大数据·elasticsearch·搜索引擎
一次旅行1 天前
AI 前沿日报 | 2026年7月13日
人工智能·搜索引擎·百度
布局呆星1 天前
Git基础操作:从本地提交到远程仓库
大数据·elasticsearch·搜索引擎
爱学习的小可爱卢2 天前
Git全解析(2W+长文):从原理到高频操作手册
大数据·elasticsearch·搜索引擎
深海鱼在掘金2 天前
深入浅出RAG——第1章:认识RAG
人工智能·搜索引擎
我爱吃土豆13 天前
AI Agent 的工作原理:从大模型问答到自主执行任务
人工智能·搜索引擎·百度·agent
峥嵘life3 天前
Repo 常用操作手册
大数据·elasticsearch·搜索引擎
Elastic 中国社区官方博客4 天前
如何为阿里云 Elasticsearch 创建推理端点,连接器,Workflow 并写入数据
大数据·人工智能·elasticsearch·搜索引擎·阿里云·云计算·全文检索