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

❣博主主页: 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中提供的注解:避免生成过多的对象,造成资源和时间的浪费,提高了自动化的执行

效率。

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

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

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

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

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

相关推荐
G皮T1 天前
【Elasticsearch】自定义评分检索
大数据·elasticsearch·搜索引擎·查询·检索·自定义评分·_score
G皮T2 天前
【Elasticsearch】深度分页及其替代方案
大数据·elasticsearch·搜索引擎·scroll·检索·深度分页·search_after
G皮T2 天前
【Elasticsearch】检索排序 & 分页
大数据·elasticsearch·搜索引擎·排序·分页·检索·深度分页
G皮T2 天前
【Elasticsearch】检索高亮
大数据·elasticsearch·搜索引擎·全文检索·kibana·检索·高亮
Leon.ENV3 天前
meilisearch-轻量级搜索引擎
搜索引擎
小袁拒绝摆烂4 天前
ElasticSearch快速入门-1
大数据·elasticsearch·搜索引擎
阿里云大数据AI技术4 天前
AI搜索 MCP最佳实践
数据库·人工智能·搜索引擎
xixi_6665 天前
文档全文搜索引擎:AnyTXT Searcher
搜索引擎
G皮T5 天前
【Elasticsearch】全文检索 & 组合检索
大数据·elasticsearch·搜索引擎·全文检索·match·query·组合检索
Elastic 中国社区官方博客14 天前
如何在 Python 中连接 Elasticsearch 并使用 Qwen3 来实现 RAG
大数据·人工智能·python·elasticsearch·搜索引擎·阿里云·全文检索