“Just Soso“ 项目测试报告

"Just Soso" 项目测试报告

一 . 项目背景

Java 官方提供给我们的 API 网站并未提供给我们搜索框 , 用户不能通过输入关键字来查找到自己想了解的语法 , 为了解决这一痛点 , 我们就设计出来 "Just Soso" 来帮助用户输入关键字来查询到自己想要了解的语法 .

二 . 项目功能

提供给用户输入框 , 用户输入想要了解的关键字 , 点击搜索 , 页面就会显示出一系列与这个关键字有关的内容 , 每个内容包括了标题、描述、URL , 用户点击标题就可以跳转到官方的语法界面进行学习

三 . 测试目的

测试 "Just Soso" 系统功能、性能、兼容性、界面、安全、易用性这六个方面是否存在问题 , 通过这六个方面尽可能找出更多错误或者缺陷来去修补

四 . 测试环境

电脑环境 : Windows 10

系统环境 : Windows 10 专业版

软件版本 : 谷歌浏览器版本 114.0.5735.248(正式版本) (64 位)

五 . 测试计划

5.1 功能测试

附件 : Just Soso 测试用例分析.xmind

图 1-1

图 1-1 是针对于功能测试罗列出的一些测试用例 , 接下来我会选取几条比较重要的用例进行功能测试

  1. 检查页面是否能正常渲染

模块 : 搜索模块

测试环境 :

  1. Windows 10 系统专业版
  2. Chrome 版本 114.0.5735.248(正式版本) (64 位)

前置条件 : 该项目已经打包上线到云服务器

测试步骤 : 打开谷歌浏览器 , 输入 http://43.143.160.85:8081/index.html , 然后回车跳转到此网页

测试数据 : http://43.143.160.85:8081/index.html

URL:http://127.0.0.1:8080/index.html

预期结果 : 页面能够正常渲染

实际结果 : 页面能够正常渲染

  1. 检测输入框能否输入元素

模块 : 搜索模块

测试环境 :

  1. Windows 10 系统专业版
  2. Chrome 版本 114.0.5735.248(正式版本) (64 位)

前置条件 : 该项目已经打包上线到云服务器

测试步骤 : 在输入框中输入 ArrayList

测试数据 : ArrayList

预期结果 : 输入框能够正常输入

实际结果 : 输入框能够正常输入

  1. 检查搜索按钮是否正常

模块 : 搜索模块

测试环境 :

  1. Windows 10 系统专业版
  2. Chrome 版本 114.0.5735.248(正式版本) (64 位)

前置条件 : 输入框已经输入了内容

测试步骤 : 点击右侧的搜索按钮

测试数据 : ArrayList

预期结果 : 搜索结果能够正常展示

实际结果 : 搜索结果能够正常展示

  1. 测试输入框输入空格能否正常检索

模块 : 搜索模块

测试环境 :

  1. Windows 10 系统专业版
  2. Chrome 版本 114.0.5735.248(正式版本) (64 位)

前置条件 : 已经打开了页面

测试步骤 : 向输入框中输入空格

测试数据 : 空格

预期结果 : 搜索结果为 0 条

实际结果 : 搜索结果为 0 条

  1. 测试输入框输入标点符号能否正常检索

模块 : 搜索模块

测试环境 :

  1. Windows 10 系统专业版
  2. Chrome 版本 114.0.5735.248(正式版本) (64 位)

前置条件 : 已经打开了页面

测试步骤 : 向输入框中输入标点符号

测试数据 : 标点符号

预期结果 : 展示出与该标点符号有关的搜索结果

实际结果 : 展示出与该标点符号有关的搜索结果

  1. 测试输入由空格分隔出的关键词能否正常检索

模块 : 搜索模块

测试环境 :

  1. Windows 10 系统专业版
  2. Chrome 版本 114.0.5735.248(正式版本) (64 位)

前置条件 : 已经打开了页面

测试步骤 : 向输入框中输入由空格分隔出的两个关键字 , 比如 : array list

测试数据 : array list

包含 array 的结果

包含 list 的结果

预期结果 : 展示出与这两个关键词都具有关联性的搜索结果

实际结果 : 展示出与这两个关键词都具有关联性的搜索结果

  1. 测试用户输入关键字之后 , 敲击回车能否进行搜索

模块 : 搜索模块

测试环境 :

  1. Windows 10 系统专业版
  2. Chrome 版本 114.0.5735.248(正式版本) (64 位)

前置条件 : 输入框中已经输入了关键词

测试步骤 : 用户输入关键词之后 , 敲击回车键

预期结果 : 展示出与该关键词有关的搜索结果

实际结果 : 并未展示出与该关键词有关的搜索结果

发现 Bug , 将 Bug 提交到管理平台

  1. 测试点击搜索结果中的标题能否跳转到详情页

模块 : 搜索模块

测试环境 :

  1. Windows 10 系统专业版
  2. Chrome 版本 114.0.5735.248(正式版本) (64 位)

前置条件 : 页面已经检索出了一系列的搜索结果

测试步骤 : 点击搜索结果中的标题 , 也就是蓝色字体

预期结果 : 展示出与该关键词有关的详情介绍

实际结果 : 展示出与该关键词有关的详情介绍

5.2 自动化测试

5.2.1 涉及模块

源文件 : Just Soso 自动化测试测试用例.xmind

5.2.2 测试模块

测试输入界面能否正常打开

前置操作 : 已经创建了驱动对象 , 并且跳转到 "Just Soso" 主页

自动化测试代码 :

java 复制代码
package com.webtest.test;

import com.webtest.common.AutoTestUtils;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;

public class InputTest {
    // 创建驱动对象
    public static ChromeDriver driver;

    // 访问登录界面
    @BeforeAll
    public static void baseControl() {
        // 1. 创建驱动对象
        driver = AutoTestUtils.createChromeDriver();

        // 2. 访问要测试的地址
        driver.get("http://43.143.160.85:8081/index.html");
    }

    // 检测页面能否正常加载
    @Test
    public void loginLoadSucc() {
        // 1. 获取输入框元素是否存在
        driver.findElement(By.cssSelector("body > div > div.header > input[type=text]"));
        // 2. 检查搜索按钮是否存在
        driver.findElement(By.cssSelector("#search-btn"));
    }

    // 驱动退出
    @AfterAll
    public static void driverQuit() {
        driver.quit();
    }
}

运行结果 :

运行成功 , 代表页面能够正常加载 , 当前用例通过

测试输入正常的关键词能否搜索

前置操作 : 页面正常渲染

自动化测试代码 :

java 复制代码
package com.webtest.test;

import com.webtest.common.AutoTestUtils;
import org.junit.jupiter.api.*;
import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;

import java.time.Duration;

@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class InputTest {
    // 创建驱动对象
    public static ChromeDriver driver;

    // 访问登录界面
    @BeforeAll
    public static void baseControl() {
        // 1. 创建驱动对象
        driver = AutoTestUtils.createChromeDriver();

        // 2. 访问要测试的地址
        driver.get("http://43.143.160.85:8081/index.html");
    }

    // 检测页面能否正常加载
    @Order(1)
    @Test
    public void loginLoadSucc() {
        // 1. 获取输入框元素是否存在
        driver.findElement(By.cssSelector("body > div > div.header > input[type=text]"));
        // 2. 检查搜索按钮是否存在
        driver.findElement(By.cssSelector("#search-btn"));
    }

    // 检测用户输入内容能否查询出结果
    @Test
    @Order(2)
    public void IndexTest() {
        // 0. 设置隐式等待
        driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(3));

        // 1. 获取到输入框元素
        driver.findElement(By.cssSelector("body > div.container > div.header > input[type=text]")).sendKeys("ArrayList");

        // 2. 获取点击按钮
        driver.findElement(By.cssSelector("#search-btn")).click();

        // 3. 检查搜索结果是否存在
        driver.findElement(By.cssSelector("body > div.container > div.result > div:nth-child(2) > a"));
    }

    // 驱动退出
    @AfterAll
    public static void driverQuit() {
        driver.quit();
    }
}

运行结果 :

运行成功 , 用户输入正常的关键字能够进行搜索 , 用例通过

测试用户输入非正常的关键词能否搜索

前置条件 : 页面正常渲染

自动化测试代码 :

java 复制代码
package com.webtest.test;

import com.webtest.common.AutoTestUtils;
import org.junit.jupiter.api.*;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.chrome.ChromeDriver;

import java.io.File;
import java.io.IOException;
import java.time.Duration;

@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class InputTest {
    // 创建驱动对象
    public static ChromeDriver driver;

    // 访问登录界面
    @BeforeAll
    public static void baseControl() {
        // 1. 创建驱动对象
        driver = AutoTestUtils.createChromeDriver();

        // 2. 访问要测试的地址
        driver.get("http://43.143.160.85:8081/index.html");
    }

    // 检测页面能否正常加载
    @Order(1)
    @Test
    public void loginLoadSucc() {
        // 1. 获取输入框元素是否存在
        driver.findElement(By.cssSelector("body > div > div.header > input[type=text]"));
        // 2. 检查搜索按钮是否存在
        driver.findElement(By.cssSelector("#search-btn"));
    }

    // 检测用户输入内容能否查询出结果
    @Test
    @Order(2)
    public void IndexTest() {
        // 0. 设置隐式等待
        driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(3));

        // 1. 获取到输入框元素
        driver.findElement(By.cssSelector("body > div.container > div.header > input[type=text]")).sendKeys("ArrayList");

        // 2. 获取点击按钮
        driver.findElement(By.cssSelector("#search-btn")).click();

        // 3. 检查搜索结果是否存在
        driver.findElement(By.cssSelector("body > div.container > div.result > div:nth-child(2) > a"));

    }

    @ParameterizedTest
    @CsvSource({"!@#$%^&", "666", "中文测试"})
    @Order(3)
    public void errorTest(String keyword) throws InterruptedException {
        // 0. 清空输入框
        driver.findElement(By.cssSelector("body > div.container > div.header > input[type=text]")).clear();

        // 1. 获取到输入框元素
        driver.findElement(By.cssSelector("body > div.container > div.header > input[type=text]")).sendKeys(keyword);

        // 2. 获取点击按钮
        driver.findElement(By.cssSelector("#search-btn")).click();
        // 防止页面过快导致上一步的结果还没消失这一步就又获取了
        Thread.sleep(1000);

        // 3. 检查搜索结果是否存在
        driver.findElement(By.cssSelector("body > div.container > div.result > div:nth-child(2) > a"));
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        // 4. 屏幕截图
        try {
            AutoTestUtils.getScreenShot("errorTest");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    // 驱动退出
    @AfterAll
    public static void driverQuit() {
        driver.quit();
    }
}

运行结果 :

用户输入特殊符号能够通过 , 输入数字和中文符号不能通过 , 符合预期

测试搜索界面元素是否显示正常

前置条件 : 用户已经输入了关键字 , 并且已经点击搜索

自动化测试代码 :

java 复制代码
package com.webtest.test;

import com.webtest.common.AutoTestUtils;
import org.junit.jupiter.api.*;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.chrome.ChromeDriver;

import java.io.File;
import java.io.IOException;
import java.time.Duration;
import java.util.Set;

@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class InputTest {
    // 创建驱动对象
    public static ChromeDriver driver;

    // 访问登录界面
    @BeforeAll
    public static void baseControl() {
        // 1. 创建驱动对象
        driver = AutoTestUtils.createChromeDriver();

        // 2. 访问要测试的地址
        driver.get("http://43.143.160.85:8081/index.html");
    }

    // 检测页面能否正常加载
    @Order(1)
    @Test
    public void loginLoadSucc() {
        // 1. 获取输入框元素是否存在
        driver.findElement(By.cssSelector("body > div > div.header > input[type=text]"));
        // 2. 检查搜索按钮是否存在
        driver.findElement(By.cssSelector("#search-btn"));
    }

    // 检测用户输入内容能否查询出结果
    @Test
    @Order(2)
    public void IndexTest() {
        // 0. 设置隐式等待
        driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(3));

        // 1. 获取到输入框元素
        driver.findElement(By.cssSelector("body > div.container > div.header > input[type=text]")).sendKeys("ArrayList");

        // 2. 获取点击按钮
        driver.findElement(By.cssSelector("#search-btn")).click();

        // 3. 检查搜索结果是否存在
        driver.findElement(By.cssSelector("body > div.container > div.result > div:nth-child(2) > a"));

    }

    // @ParameterizedTest
    // @CsvSource({"!@#$%^&", "666", "中文测试"})
    // @Order(3)
    public void errorTest(String keyword) throws InterruptedException {
        // 0. 清空输入框
        driver.findElement(By.cssSelector("body > div.container > div.header > input[type=text]")).clear();

        // 1. 获取到输入框元素
        driver.findElement(By.cssSelector("body > div.container > div.header > input[type=text]")).sendKeys(keyword);

        // 2. 获取点击按钮
        driver.findElement(By.cssSelector("#search-btn")).click();
        Thread.sleep(1000);

        // 3. 检查搜索结果是否存在
        driver.findElement(By.cssSelector("body > div.container > div.result > div:nth-child(2) > a"));
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        // 4. 屏幕截图
        try {
            AutoTestUtils.getScreenShot("errorTest");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Test
    @Order(3)
    public void checkItems() {
        // 1. 定位到标题元素,看是否存在
        driver.findElement(By.cssSelector("body > div.container > div.result > div:nth-child(2) > a"));

        // 2. 定位到正文描述,看是否存在
        driver.findElement(By.cssSelector("body > div.container > div.result > div:nth-child(2) > div.desc"));

        // 3. 定位到 URL 元素,看是否存在
        driver.findElement(By.cssSelector("body > div.container > div.result > div:nth-child(2) > div.url"));
    }

    // 驱动退出
    @AfterAll
    public static void driverQuit() {
        driver.quit();
    }
}

运行结果 :

页面显示正常 , 用例通过

测试用户点击标题是否能跳转到对应的文档界面

前置条件 : 用户已经输入了关键字 , 并且已经点击搜索

自动化测试代码 :

java 复制代码
package com.webtest.test;

import com.webtest.common.AutoTestUtils;
import org.junit.jupiter.api.*;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.chrome.ChromeDriver;

import java.io.File;
import java.io.IOException;
import java.time.Duration;
import java.util.Set;

@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class InputTest {
    // 创建驱动对象
    public static ChromeDriver driver;

    // 访问登录界面
    @BeforeAll
    public static void baseControl() {
        // 1. 创建驱动对象
        driver = AutoTestUtils.createChromeDriver();

        // 2. 访问要测试的地址
        driver.get("http://43.143.160.85:8081/index.html");
    }

    // 检测页面能否正常加载
    @Order(1)
    @Test
    public void loginLoadSucc() {
        // 1. 获取输入框元素是否存在
        driver.findElement(By.cssSelector("body > div > div.header > input[type=text]"));
        // 2. 检查搜索按钮是否存在
        driver.findElement(By.cssSelector("#search-btn"));
    }

    // 检测用户输入内容能否查询出结果
    @Test
    @Order(2)
    public void IndexTest() {
        // 0. 设置隐式等待
        driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(3));

        // 1. 获取到输入框元素
        driver.findElement(By.cssSelector("body > div.container > div.header > input[type=text]")).sendKeys("ArrayList");

        // 2. 获取点击按钮
        driver.findElement(By.cssSelector("#search-btn")).click();

        // 3. 检查搜索结果是否存在
        driver.findElement(By.cssSelector("body > div.container > div.result > div:nth-child(2) > a"));

    }

    // @ParameterizedTest
    // @CsvSource({"!@#$%^&", "666", "中文测试"})
    // @Order(3)
    public void errorTest(String keyword) throws InterruptedException {
        // 0. 清空输入框
        driver.findElement(By.cssSelector("body > div.container > div.header > input[type=text]")).clear();

        // 1. 获取到输入框元素
        driver.findElement(By.cssSelector("body > div.container > div.header > input[type=text]")).sendKeys(keyword);

        // 2. 获取点击按钮
        driver.findElement(By.cssSelector("#search-btn")).click();
        Thread.sleep(1000);

        // 3. 检查搜索结果是否存在
        driver.findElement(By.cssSelector("body > div.container > div.result > div:nth-child(2) > a"));
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        // 4. 屏幕截图
        try {
            AutoTestUtils.getScreenShot("errorTest");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Test
    @Order(3)
    public void checkItems() {
        // 1. 定位到标题元素,看是否存在
        driver.findElement(By.cssSelector("body > div.container > div.result > div:nth-child(2) > a"));

        // 2. 定位到正文描述,看是否存在
        driver.findElement(By.cssSelector("body > div.container > div.result > div:nth-child(2) > div.desc"));

        // 3. 定位到 URL 元素,看是否存在
        driver.findElement(By.cssSelector("body > div.container > div.result > div:nth-child(2) > div.url"));
    }

    @Test
    @Order(4)
    public void checkIndex() {
        // 1. 定位到标题元素,模拟点击操作
        driver.findElement(By.cssSelector("body > div.container > div.result > div:nth-child(2) > a")).click();

        // 2. 切换标签页
        // 获取全部标签页
        Set<String> handles = driver.getWindowHandles();
        // 获取当前标签页
        String curHandle = driver.getWindowHandle();
        // 遍历所有标签页
        for (String handle : handles) {
            // 当前标签页不是跳转后的标签页 -> 跳转
            if (handle != curHandle) {
                driver.switchTo().window(handle);
            }
        }

        // 3. 获取 Java 标识是否存在
        driver.findElement(By.cssSelector("body > div.topNav > div.aboutLanguage > strong"));
    }

    // 驱动退出
    @AfterAll
    public static void driverQuit() {
        driver.quit();
    }
}

运行结果 :

页面能够正常跳转 , 该用例通过

5.2.3 用例数量

项目中一共测试了 8 个用例点 , 如图 :

5.2.4 运行结果

成功数量 : 6 个

失败数量 : 2 个

失败的原因是用户输入数字和中文符号本身就是搜索不出结果 , 是正常现象

测试覆盖率 : 20%

该项目选取的是核心测试用例来进行自动化测试 , 所以测试覆盖率会比较低

5.2.5 自动化测试的亮点

  1. 我们使用了 JUnit5 中提供的注解 : 他避免了我们使用 main 方法去运行测试用例 , 避免生成过多的对象 , 造成资源和时间的浪费 , 提高了自动化的执行效率
  2. 只创建一次驱动对象 , 避免每个用例重复创建驱动对象 , 造成时间和资源的浪费
  3. 使用参数化 : 保持用例的简洁 , 提高代码的可读性
  4. 测试套件 : 降低了测试人员的工作量 , 通过套件一次执行所有要运行的测试用例
  5. 使用了隐式等待 : 提高了自动化运行效率 , 提高了自动化的稳定性
  6. 使用了屏幕截图 : 方便后续问题的追溯以及解决

六 . 风险评估

目前该系统最大的问题就是只能支持小部分人使用 , 当许多人同时访问的时候 , 就会访问失败 .

而且背景图渲染过慢影响用户体验感 , 可以将背景图进行压缩

七 . 附件

  1. 自动化测试的代码

JustSosoAutoTest.zip

  1. 自动化测试样例文件

Just Soso 测试用例分析.xmind
Just Soso 自动化测试测试用例.xmind

  1. 项目报告文件
    Just Soso 测试报告.md
相关推荐
会写代码的饭桶9 小时前
Jenkins 实现 Vue 项目自动化构建与远程服务器部署
vue.js·自动化·jenkins
Super Rookie11 小时前
Tomcat 自动化脚本安装方案
运维·tomcat·自动化
qinxue72211 小时前
Jenkins自动化配置--CICD流水线
运维·自动化·jenkins
川石课堂软件测试13 小时前
自动化测试之 Cucumber 工具
数据库·功能测试·网络协议·测试工具·mysql·单元测试·prometheus
weixin_3077791320 小时前
Clickhouse导出库的表、视图、用户和角色定义的SQL语句
开发语言·数据库·算法·clickhouse·自动化
程序员三藏20 小时前
银行测试:第三方支付平台业务流,功能/性能/安全测试方法
自动化测试·软件测试·python·功能测试·测试工具·职场和发展·安全性测试
废弃的小码农21 小时前
测试基础--Day01--软件测试基础理论
python·功能测试·测试工具
文静小土豆1 天前
Ansible 自动化部署K8S1.34.1
kubernetes·自动化·ansible
2501_915909061 天前
原生 iOS 开发全流程实战,Swift 技术栈、工程结构、自动化上传与上架发布指南
android·ios·小程序·uni-app·自动化·iphone·swift
紧固视界2 天前
机械臂装配自动化推动紧固件设计革新
运维·自动化