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

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

效率。

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

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

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

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

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

相关推荐
小园子的小菜1 小时前
深度剖析Elasticsearch数据写入与读取:从分片同步到核心组件协同
大数据·elasticsearch·搜索引擎
怀璧其罪19 小时前
aleph-node Node upgrade instructions 节点升级说明
大数据·elasticsearch·搜索引擎
邮专薛之谦1 天前
Git复习(查询版本)
大数据·elasticsearch·搜索引擎
KANGBboy1 天前
ES 生产排查
大数据·elasticsearch·搜索引擎
JavaBoy_XJ1 天前
电商系统中ES检索技术设计和运用
大数据·elasticsearch·搜索引擎
小园子的小菜2 天前
Elasticsearch高阶用法实战:从数据建模到集群管控的极致优化
大数据·elasticsearch·搜索引擎
老陈头聊SEO2 天前
AI与SEO策略结合下的关键词优化新发现
其他·搜索引擎·seo优化
脑极体3 天前
穿越沙海:中国AI的中东远征
人工智能·搜索引擎
LaughingZhu4 天前
Product Hunt 每日热榜 | 2025-11-14
人工智能·经验分享·搜索引擎·产品运营
liliangcsdn4 天前
如何基于DSL脚本进行elasticsearch向量检索示例
大数据·elasticsearch·搜索引擎