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

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

效率。

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

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

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

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

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

相关推荐
Elastic 中国社区官方博客19 小时前
Elasticsearch:列式索引模式 - Columnar index mode
大数据·数据库·elasticsearch·搜索引擎·全文检索
李恒-聆机智能专精数采20 小时前
新网站在搜索引擎完全搜不到怎么优化?(四)——提交搜索引擎搜索资源平台
搜索引擎·seo·next.js·百度收录·网站优化
LaughingZhu2 天前
Product Hunt 每日热榜 | 2026-08-09
人工智能·深度学习·神经网络·搜索引擎·百度
独行侠影a3 天前
Elasticsearch海量数据查询优化:深度分页与聚合查询提速方案
大数据·elasticsearch·搜索引擎
liu_sir_3 天前
3572_a16_3566_A11_A9等解决机器接电池或者插DC电源上电的时候不要立马开机,要通过电源按键按下之后才开机
大数据·elasticsearch·搜索引擎
John jj4 天前
拆解 Telegram 群组频道收录市场:三类方案,一个可运行的评分模型,目前TG中文人工评分加模型评分机制——LetsTG收录“快速”、“无门槛”
大数据·后端·python·深度学习·搜索引擎·django·全文检索
Elastic 中国社区官方博客5 天前
使用 Elasticsearch open inference API 对 OpenAI chat completions 进行支持
大数据·elasticsearch·搜索引擎·全文检索·jenkins
LaughingZhu5 天前
Product Hunt 每日热榜 | 2026-08-05
人工智能·深度学习·神经网络·搜索引擎·百度
李恒-聆机智能专精数采5 天前
新网站在搜索引擎完全搜不到怎么优化?(一)
前端·搜索引擎·性能优化·制造·ai编程·程序员创富
程序员小八7776 天前
一篇文章讲透 Elasticsearch:从倒排索引到实战落地
大数据·elasticsearch·搜索引擎