测试方案—Android应用测试指南(7)

发表于:2016-3-18 10:13

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:李江    来源:51Testing软件测试网原创

  第7章  测 试 方 案
  本章将列出测试过程中经常遇到的问题,通过比较接近实际的例子,将前面章节中讲到的原则、技术应用到里面去。我们将会用处方的形式展现给大家看,方便大家根据自己项目的需要选择性学习。
  本章包含下面几个主题:
  "  Android单元测试;
  "  测试行为和应用程序;
  "  测试数据库和ContentProviders的测试;
  "  测试本地和远程服务;
  "  测试UI交互;
  "  测试异常;
  "  测试转换;
  "  测试内存泄露。
  通过这章学习,你会对测试自己的工程需要干什么,用到什么有一定的了解。
  7.1  Android单元测试
  我们知道,对工程中的一些组件的测试用例,真的需要在一个独立的,跟底层系统隔离开的环境中才好执行。在执行这些用例的时候,我们要选择一个高权限高层次的类,要可以除去被测模块对其他模块的依赖,但是又不会影响一些基础架构。
  对于这个类,我们有个候选类,那就是AndriodTestCase。样例详情可以在Andriod CTS测试集合中下载,如框7.1所示。
  框7.1
/*
* Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.android.cts.appaccessdata;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import android.test.AndroidTestCase;
/**
* Test that another app's private data cannot be accessed.
*
* Assumes that {@link APP_WITH_DATA_PKG} has already created
the private data.
*/
public class AccessPrivateDataTest extends AndroidTestCase {
/**
* The Android package name of the application that owns
the private data
*/
private static final String APP_WITH_DATA_PKG =
"com.android.cts.appwithdata";
本文选自《Android应用测试指南》第七章,本站经人民邮电出版社和作者的授权。
版权声明:51Testing软件测试网获人民邮电出版社和作者授权连载本书部分章节。
任何个人或单位未获得明确的书面许可,不得对本文内容复制、转载或进行镜像,否则将追究法律责任。
21/212>
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号