Software Testing - Quality guardian

Software testing is the software development process goalkeeper, the importance of commercial software, no doubt, large companies tend to invest a lot of costs in the testing phase of the software to ensure software

The stability of small software developers also need to link software testing software modifications and optimization.

Divided according to the development stage, the test software can be divided into unit testing, integration testing, system testing and acceptance testing

First, the white-box testing

Test environment window10, eclipse Java 2019

Testing tools: junit, ant, SourceMonitor, EclEmma

a) Junit uses examples

Category: Unit Testing

Download: If using eclipse environment, without having to download

   Right Project -> Properties -> Java Build Path -> Add Library -> select JUnit

Figure is lower success appears:

Examples of program code:

package calcue;

public class calculate {
    
    public int Add(int a,int b) 
    {//求和
        return a+b;
    }
    public int Subtract(int a,int b) 
    {// a-b
        return a-b;
    }
    
    public double Factor(int n) 
    {//求阶乘
        int i;
        double sum=1;
        for(i=1;i<=n;i++) sum*=i;
        
        if (n==0 || n==1) return 1;
        else return sum;
        
    }
    public int Divisor(int a,int b) 
    {//求最大公约数
        int tt=1;
        for (int i=1; i<=a;i++) if ( a%i == 0 && b%i ==0) tt= i; 
        return tt;
    }
    
}

Examples of test code:

package calcue;

import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;

public class calculateTest {
    calculate aa = new calculate();

    //测试用例
    @Test
    void testAdd() {
         assertEquals(3,aa.Add(1,2));  
         System.out.println("test0");  
    }
    @Test
    void testFactor() {
         assertEquals(Double.valueOf(120),aa.Factor(5));  
         System.out.println("test1");  
    }
    @Test
    void testDivisor() {
         assertEquals(3,aa.Divisor(15,27));  
         System.out.println("test2");  
    }
}

 It is expected (test code) and the actual operating results of automatic matching:

Results are as follows:

Red marquee at the success rates were the order of the tests and test items:

Changing expectations were being given a reminder:

Junit use Summary:

Test Method 1. The order of execution: @BeforeClass -> @ Before -> @ Test -> @ After -> @ AfterClass (order is not unique)

You must use @Test 2. Test Method

3. Test methods must be modified to use public void

4. Create a source code directory to store test code

5. Test classes and packages should be tested packages such as

6. The method of each of the test cell must be independently tested, which method does not rely on any

 

b) EclEmma uses examples (using the same codes as described above)

Category: Coverage test

 

* Right-package -> Export Session -> select Coverage Report can generate an HTML file

* HTML reports can drill down, you can view the code coverage by clicking method

Each column names meanings:

Missed Instruction: code coverage

Missed Branches: logic branch coverage

Missed Cxty:判断执行数

Missed Lines:代码行数

Methods:方法个数

 

*可以通过点击方法查看源码

 

EclEmma工具:https://www.cnblogs.com/Ming8006/p/5811425.html

 

 c)Ant使用示例

种类:自动报告生成工具

建立方法:右键项目名 -> 点击Properties -> 选择Builders -> 选择Ant Builder

*eclipse集成环境会自动生成相匹配的build.xml文件,相比于手动配置更加便捷

Ant工具:https://blog.csdn.net/qq_31896043/article/details/52185220

d)SourceMoniter

种类:复杂度分析工具

当代码过于简单,测试无效,如下图:

使用流程:

检测所有代码的复杂度总和:

检测的代码按照类分的详细信息:(双击总和表)

Source Monitor工具:https://www.cnblogs.com/xuehanyu/p/4520965.html

Source Monitor使用总结:

1.代码兼容性好,支持CC++C#JavaVBDelphiHTML。

2.针对不同的语言,输出不同的代码度量值。

 

二、服务器测试

在搭建软件平台的过程中,要使用到服务器,故服务器的性能好坏也影响到软件的性能。

 

测试环境:

Windows7 i5-4590CPU @ 3.30GHz;RAM:8GB;64位操作系统

JDK 1.8

测试软件 :Apache JMeter 3.2

FTP服务软件:Quick Easy FTP Server

 

Quick Easy FTP Server是一个全中文FTP服务器软件,反应迅速,操作方便,实现了标准FTP服务器所具有的功能。

该软件具有以下特点:

  1.软件安装程序极小,但性能毫不逊色于专业的那些FTP服务器软件

  2.功能全面.具备完整的帐户管理,便捷的服务器配置,安全性设置,在线用户信息, 服务器日志,实时数据统计,检软件界面查更新一应俱全

  3.支持断点续传

  4.完整的帮助系统

  5.全中文,更适合中国人使用。

界面

 

 

简单操作

在浏览器中搜索 FTP:\\192.168.1.101 (服务器IP)

展示服务器根目录路径下所存储的文件信息

最开始的根目录路径 G:\QB\work\课程论文,包含我存储的两个文档

 

 

 

在根路径下添加文件,刷新网页,查看结果。

显示text.doc文件

 

 

 Jmeter

 简要概述

  Apache JMeter是100%的纯java桌面应用程序,被设计为用于测试客户 /服务端结构的软件(例如web应用程序)。它可以用来测试静态和动态资 源的性能,例如:静态文件,Java Servlet,CGI Scripts,Java Object,数 据库和FTP服务器等等。JMeter可用于模拟大量负载来测试一台服务器,网 络或者对象的健壮性或者分析不同负载下的整体性能。
     同时,JMeter可以帮助你对你的应用程序进行回归测试。通过你创建 的测试脚本和assertions来验证你的程序返回了所期待的值。为了更高的 适应性,JMeter允许你使用正则表达式来创建这些assertions.

 

优点:

1.开源,他是一款开源的免费软件,使用它你不需要支付任何费用,

2. 小巧,相比LR的庞大(最新LR11将近4GB),它非常小巧,不需 要安装,但需要JDK环境,因为它是使用java开发的工具。

 3.功能强大,jmeter设计之初只是一个简单的web性能测试工具,但 经过不段的更新扩展,现在可以完成数据库、FTP、LDAP、WebService等方 面的测试。因为它的开源性,当然你也可以根据自己的需求扩展它的功能。

 

简单使用

添加线程组->添加FTP默认请求->添加FTP请求->添加查看结果树

 

 

FTP请求配置:

 

 

 

服务器IP和端口号:

quick easy ftp服务器配置

 

 

 

登录配置:

quick easy ftp用户账号管理

 

 

 

测试上传操作:

本地文件内容设置,如图

 

 

远程文件内容设置为空:

 

 

上传操作执行完成:

 

 

 

最开始选择了get,下载操作,而远程文件为空,无下载资源,故FTP请求 失败。

更改为put操作。

远程文件更新,结果如图:

 

 

 

清空本地文件

 

 

 

远程文件内容如图:

 

 

 

更改操作为get,下载操作

下载成功,本地文件结果如图;

 

 

 

探究下载过程的服务器的实际动作

查看quick easy ftp的服务器日志

 

 

为了便于分辨,将线程数改为1

 

 

获得一次完整的执行过程

 

 

其中开始和结束都为quick easy ftp的欢迎和结束词

 

 

修改验证:

 

 

发生更改:

 

 

 

解读日志中出现的命令

 

1.USER命令:(访问命令)

格式:USER<username>

功能:制定登录的用户名,以便服务器进行身份验证

2.PASS命令:(访问命令)

格式:PASS<password>

功能:指定用户口令,该命令必须跟在登录命令之后

3.PASV命令:(模式设置命令)

格式:pasv

功能:该命令告诉FTP服务器,让FTP服务器在指定的数据端口进行监听, 进入被动接收请求的状态

4.RETR命令:(文件传输命令)

格式:RETR<filename>

功能:请求服务器将指定路径内的文件复制到客户端,也即下载指定的文件

5.QUIT命令:(访问命令)

格式:QUIT

功能:关闭与服务器的连接

 

如果把同时发出5个请求,是执行5次这些指令吗?

线程数设为5

 

请求成功:

 

查看日志,5次执行的指令没有变化。

 

将模式改为上传进行比较

 

请求成功

 

查看日志:

 

 

可以看到仅更改了一个指令:

6.STOR命令:(文件传输命令)

格式:STOR<filename>

功能:上传一个指定的文件,并将其存储在指定的位置

 

 jmeter测试quick easy ftp server的上传下载性能(仅提供一次示例,将线程数更改重复操作即可)

 

B) 130进程:

请求成功:

 

 

汇总报告:

 

 

汇总图:

 

 

图形结果:

 

表格结果:

 

Quick easy ftp server使用总结:

Quick easy FTP Server作为一个轻量级的小型FTP服务器,功能全面,操作方面,在访问额度为1~50时,可以保持较好的稳定性,在访问额度达到100时,下载的异常率仅为3.73%,适合作为本次小组项目的临时服务器,后续若项目落地,服务器必须进行更换。

Guess you like

Origin www.cnblogs.com/blackDuck/p/10963233.html