一起买beta版模块单元测试

一起买beta版模块接口单元测试

测试目的

保证代码质量,对各个模块进行单元测试,不仅可以有效地保证代码的可靠性,让模块在与别的模块整合时出现更少的错误。

而且不用每次启动程序而等待浪费时间。

单元描述

  • 登录接口

    回调函数返回登录信息

  • 获取用户信息接口

    回调函数返回用户个人信息

  • 获取我的帖子接口

    回调函数返回我的帖子列表

  • 修改用户信息接口

    回调函数返回修改后的结果

  • 查看帖子详情

    回调函数返回帖子详情

  • 管理员获得被举报帖子接口

    回调函数返回被举报的帖子列表。

测试过程

  • 用户登录测试
    @Test
public void testCallbackLoginInfo() throws Exception { GetCallbackLoginInfo(new HttpCallbackListener() {
@Override
public void onFinish(LoginInfo response) {
System.out.println("respons.getReturnUserName=:" + response.getReturnUserName());
System.out.println("respons.getReturnSuccess=:" + response.getReturnSuccess());
System.out.println("respons.getReturnMessage=:" + response.getReturnMessage());
System.out.println("respons.getPhoneNumber=:" + response.getPhoneNumber());
System.out.println("respons.getEamilAddress=:" + response.getEamilAddress());
System.out.println("respons.getSex=:" + response.getSex());
System.out.println("respons.getName=:" + response.getName());
System.out.println("respons.getBirthday=:" + response.getBirthday());
System.out.println("respons.getSchool=:" + response.getSchool());
System.out.println("respons.getOccpuation=:" + response.getOccupation());
System.out.println("respons.getHeadPortati=:" + response.getHeadPortait());
System.out.println("respons.getDescription=:" + response.getDescription());
}

测试结果:

一起买beta版模块单元测试

  • 获取用户信息测试
    @Test
public void testCallbackPersonInformation() throws Exception { GetCallbackPersonInformation(new HttpCallbackListener() {
@Override
public void onFinish(PersonalInformation response) {
System.out.println("respons.getName:" + response.getName());
System.out.println("respons.getSex=:" + response.getSex());
System.out.println("respons.getEmilAddress=:" + response.getEmilAddress());
System.out.println("respons.getUserName=:" + response.getUserName());
System.out.println("respons.getBirthday=:" + response.getBirthday());
System.out.println("respons.getDescription=:" + response.getDescription());
System.out.println("respons.getHeadPortati=:" + response.getHeadPortati());
System.out.println("respons.getOccpation=:" + response.getOccpation());
System.out.println("respons.getSchool=:" + response.getSchool());
System.out.println("respons.getPhoneNumber=:" + response.getPhoneNumber());
}

测试结果:

一起买beta版模块单元测试

  • 修改用户信息
    @Test
public void testCallBoolean() throws Exception { GetCallbackBoolean(new HttpCallbackListener() {
@Override
public void onFinish(boolean response) {
System.out.println("respons=:" + response);
}

测试结果:

一起买beta版模块单元测试

  • 查看帖子详情
    @Test
public void testCallbackPostDetail() throws Exception { GetCallbackPostDetail(new HttpCallbackListener() {
@Override
public void onFinish(PostsDetail response) {
System.out.println("response.getMessageId=:" + response.getMessageId());
System.out.println("response.getTitle=:" + response.getTitle());
System.out.println("response.getCommoditye=:" + response.getCommodity());
System.out.println("response.getContact=:" + response.getContact());
System.out.println("response.getDay=:" + response.getDay());
System.out.println("response.getHour=:" + response.getHour());
System.out.println("response.getDescription=:" + response.getDescription());
System.out.println("response.getLocation=:" + response.getLocation());
System.out.println("response.getPhoto=:" + response.getPhoto());
System.out.println("response.getPostTime=:" + response.getPostTime());
System.out.println("response.getPrice=:" + response.getPrice());
System.out.println("response.getMember=:" + response.getMember());
System.out.println("response.getType=:" + response.getType());
System.out.println("response.getUnit=:" + response.getUnit());
}

测试结果:

一起买beta版模块单元测试

  • 获取我的帖子
    @Test
public void testCallbackPosts() throws Exception { GetCallbackPosts(3,new HttpCallbackListener() {
@Override
public void onFinish(Posts[] response) {
for (int i =0 ;i<response.length; i++) {
System.out.println("response["+i+"].getMessageId:"+response[i].getMessageId());
System.out.println("response["+i+"].getTitle:"+response[i].getTitle());
System.out.println("response["+i+"].getPhoto:"+response[i].getPhoto());
System.out.println("response["+i+"].getPostTime:"+response[i].getPostTime());
System.out.println("response["+i+"].getHeadPortait:"+response[i].getHeadPortait());
System.out.println("response["+i+"].getUserName:"+response[i].getUserName()); }
}

测试结果:

一起买beta版模块单元测试

结果统计

模拟从服务器返回的所有可能的数据,均能成功接收。

质量评估

由于精心修改过,总体没有什么问题

测试总结

整个测试过程主要是模拟服务器返回数据。结果比较成功,所有数据能成功返回。

但是关于线程的单元测试,查阅了大量的资料也没能得到满意的答案。

所以未能对各个模块进行准确的单元测试。总的来说,相比于Alpha版本,已经明显体会到单元测试的意义及重要性。

上一篇:bay——RAC 表空间时数据文件误放置到本地文件系统-介质恢复.txt


下一篇:Oracle数据文件丢失,数据库如何打开或恢复