欢迎来到天天文库
浏览记录
ID:34760493
大小:212.84 KB
页数:4页
时间:2019-03-10
《安卓开发基础教程02》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、不倒翁学习笔记1、Log日志(熟练)重点:1Log自身的一套日志输出Log.v(TAG,"verbose");Stringstr=null;str.substring(9);Log.d(TAG,"debug");Log.i(TAG,"info");Log.w(TAG,"warn");Log.e(TAG,"error");2添加过滤器2、测试的相关概念(了解)1看是否有源代码1.1黑盒测试16w1.2白盒测试必须对应代码的每个模块都非常熟悉30w2时间单元测试:程序员自己模块测试:组内测试集成测试:所有的代码搞到一起来测试系统测试:亚太地区:google认证
2、中心香港贴牌属于android系统(cts测试)cts测试:防止各类手机定制商修改android代码3压力程度3.1猴子测试monkey3.2冒烟测试3.Android的单元测试1首先在应用层application里面写上2在application外写上3、id:targetPackage="com.ym.text">3新建java文件时候注意继承android.test.AndroidTestcase类4写测试内容,最后在outline里面运行要测试的方法【Example】业务类要测试的程序publicclassperson{privateStringname=null;publicStringgetFirstName(){returnname.substring(7);}publicintadd(intx,inty){returnx+y;}}测试类,测试以上方法publicclasspersonTeste4、xtendsAndroidTestCase{privatestaticfinalStringTAG="persontest";publicvoidtestGetFirstName(){personps=newperson();Stringfirstname=ps.getFirstName();Log.i(TAG,"firstname:"+firstname);}publicvoidtestAdd(){personps=newperson();intactual=ps.add(1,1);//断言测试2为期待的值,actual为实际的值//assertactu5、al==2;Assert.assertEquals(2,actual);}}4、文件的访问权限(熟练)在drwxr--rwx中,前一个字母是文件的类型后面的九个字母三个三个一分,前三个是所有者的权限,中间三个是所属组的权限,后面三个是其他人权限,r代表读w代表写x代表可以执行文件是-文件夹是d不倒翁学习笔记文件操作的四种模式privateappendworldreadworldwriteword先写四个按钮,每个按钮添加一些方法FileOutputStreamfos=openFileOutput(“private.txt”,Context.Mode_pri6、vate)createFile(Stringname,intmode,Stringcontent)三个参数文件名,文件的操作模式,文件的内容privatevoidcreateFile(Stringname,intmode,Stringcontent){try{FileOutputStreamfos=openFileOutput(name,mode);fos.write(content.getBytes());fos.close();}catch(Exceptione){e.printStackTrace();}}私有的会把原来的内容进行覆盖,append会7、在原有的基础上添加5.Android下的数据读写和保存(熟练)以登录为例//回显数据//回显数据StringpackageName=getPackageName();Filefile=newFile("/data/data/"+packageName+"/user.txt");//构建文件对象if(file.exists()){//判断文件是否存在try{FileReaderfr=newFileReader(file);BufferedReaderbr=newBufferedReader(fr);Stringcontent=br.readLine();et8、_name.setText(content);//设置给et_na
3、id:targetPackage="com.ym.text">3新建java文件时候注意继承android.test.AndroidTestcase类4写测试内容,最后在outline里面运行要测试的方法【Example】业务类要测试的程序publicclassperson{privateStringname=null;publicStringgetFirstName(){returnname.substring(7);}publicintadd(intx,inty){returnx+y;}}测试类,测试以上方法publicclasspersonTeste
4、xtendsAndroidTestCase{privatestaticfinalStringTAG="persontest";publicvoidtestGetFirstName(){personps=newperson();Stringfirstname=ps.getFirstName();Log.i(TAG,"firstname:"+firstname);}publicvoidtestAdd(){personps=newperson();intactual=ps.add(1,1);//断言测试2为期待的值,actual为实际的值//assertactu
5、al==2;Assert.assertEquals(2,actual);}}4、文件的访问权限(熟练)在drwxr--rwx中,前一个字母是文件的类型后面的九个字母三个三个一分,前三个是所有者的权限,中间三个是所属组的权限,后面三个是其他人权限,r代表读w代表写x代表可以执行文件是-文件夹是d不倒翁学习笔记文件操作的四种模式privateappendworldreadworldwriteword先写四个按钮,每个按钮添加一些方法FileOutputStreamfos=openFileOutput(“private.txt”,Context.Mode_pri
6、vate)createFile(Stringname,intmode,Stringcontent)三个参数文件名,文件的操作模式,文件的内容privatevoidcreateFile(Stringname,intmode,Stringcontent){try{FileOutputStreamfos=openFileOutput(name,mode);fos.write(content.getBytes());fos.close();}catch(Exceptione){e.printStackTrace();}}私有的会把原来的内容进行覆盖,append会
7、在原有的基础上添加5.Android下的数据读写和保存(熟练)以登录为例//回显数据//回显数据StringpackageName=getPackageName();Filefile=newFile("/data/data/"+packageName+"/user.txt");//构建文件对象if(file.exists()){//判断文件是否存在try{FileReaderfr=newFileReader(file);BufferedReaderbr=newBufferedReader(fr);Stringcontent=br.readLine();et
8、_name.setText(content);//设置给et_na
此文档下载收益归作者所有