当前位置: 首页 > news >正文

7474网页游戏大全重庆seo报价

7474网页游戏大全,重庆seo报价,网站开发投稿可行吗,网络推广运营主要做什么1. 单元测试Junit 1.1 什么是单元测试?(掌握) 对部分代码进行测试。 1.2 Junit的特点?(掌握) 是一个第三方的工具。(把别人写的代码导入项目中)(专业叫法:…

1. 单元测试Junit

1.1 什么是单元测试?(掌握)

对部分代码进行测试。

1.2 Junit的特点?(掌握)

  • 是一个第三方的工具。(把别人写的代码导入项目中)(专业叫法:导jar包)

  • 如果运行结果显示绿色,表示运行结果是正确的。

    如果运行结果显示红色,表示运行结果是错误的。

1.3 基本用法:(掌握)

1,一定要先写一个方法。

2,在这个方法的上面写@Test

3,鼠标点一下@Test 按alt + 回车,点击Junit4

​ 此时就可以自动导包。

​ 如果自动导包失败(连接外网,或者自己手动导包)

​ 如果导包成功在左下角就会出现Junit4的相关jar包

手动导包(掌握)

1,在当前模块下,右键新建一个文件夹(lib)

2,把今天资料里面的两个jar包,拷贝到lib文件夹里面

3,选中两个jar右键点击add as a lib…

4,到代码中,找到@Test,按alt + 回车,再来导入。

运行测试代码(掌握)

  • 只能直接运行无参无返回值的非静态方法
  • 想要运行谁,就右键点击哪个方法。如果想要运行一个类里面所有的测试方法,选择类名,有点点击即可。

Junit正确的打开方式(正确的使用方式)(掌握)

注意点:并不是直接在要测试的方法上面直接加@Test

原因:因为要测试的方法有可能是有参数的,有返回值,或者是静态的。

正确的使用方式:(掌握)

1,新建测试类

2,新建测试方法(要测试的方法名 + Test) methodTest

3,在这个方法中直接调用要测试的方法

4,在测试方法的上面写@Test

代码示例:

//真正用来测试的类
//测试用例(测试类)
public class JunitTest {//在这个类里面再写无参无返回值的非静态方法//在方法中调用想要测试的方法@Testpublic void method2Test(){//调用要测试的方法JunitDemo1 jd = new JunitDemo1();jd.method2(10);}
}

实际开发中单元测试的使用方式(掌握)

需求:测试File中的delete方法,写的是否正确(掌握)

开发中的测试原则:

不污染原数据。

代码示例:

public class JunitDemo3 {//在实际开发中,真正完整的单元测试该怎么写?//前提://以后在工作的时候,测试代码不能污染原数据。(修改,篡改)//1.利用Before去对数据做一个初始化的动作//2.利用Test真正的去测试方法//3.利用After去还原数据//需求:测试File类中的delete方法是否书写正确???@Beforepublic void beforemethod() throws IOException {//先备份File src = new File("C:\\Users\\moon\\Desktop\\a.txt");File dest = new File("C:\\Users\\moon\\Desktop\\copy.txt");FileInputStream fis = new FileInputStream(src);FileOutputStream fos = new FileOutputStream(dest);int b;while((b = fis.read()) != -1){fos.write(b);}fos.close();fis.close();}//作为一个标准的测试人员,运行完单元测试之后,不能污染原数据//需要达到下面两个要求://1.得到结果//2.a.txt还在而且其他的备份文件消失@Testpublic void method(){File file = new File("C:\\Users\\moon\\Desktop\\a.txt");boolean delete = file.delete();//检查a.txt是否存在boolean exists = file.exists();//只有同时满足了下面所有的断言,才表示delete方法编写正确Assert.assertEquals("delete方法出错了",delete,true);Assert.assertEquals("delete方法出错了",exists,false);}@Afterpublic void aftermethod() throws IOException {//还要对a.txt做一个还原File src = new File("C:\\Users\\moon\\Desktop\\copy.txt");File dest = new File("C:\\Users\\moon\\Desktop\\a.txt");FileInputStream fis = new FileInputStream(src);FileOutputStream fos = new FileOutputStream(dest);int b;while((b = fis.read()) != -1){fos.write(b);}fos.close();fis.close();//备份数据要删除src.delete();}
}

作业:

​ 测试Properties类中的store方法是否书写正确?

开发心得:

1.Before 准备数据

2.Test 测试方法

3.After 还原

Before

准备数据
1.创建Properties的对象
2.put数据到集合当中
//只不过在下面的方法中,我们也需要用到Properties的对象,所以写完之后要挪到成员位置

Test

调用store方法,保存数据到本地文件断言1:判断当前文件是否存在
断言2:文件的大小一定是大于0
断言3:再次读取文件中的数据,判断是否跟集合中一致结论:如果所有的断言都通过了,表示store方法是正确的

After

把本地文件给删除

扩展点:

在单元测试中,相对路径是相对当前模块而言的。

代码示例:

File file = new File("aweihaoshuai.txt");
file.createNewFile();
//此时是把aweihaoshuai.txt这个文件新建到模块中了。

文章转载自:
http://dinncorewire.zfyr.cn
http://dinncopye.zfyr.cn
http://dinncoplasticise.zfyr.cn
http://dinncounche.zfyr.cn
http://dinncormt.zfyr.cn
http://dinncowastewater.zfyr.cn
http://dinncogamopetalous.zfyr.cn
http://dinncowhifflow.zfyr.cn
http://dinncorongeur.zfyr.cn
http://dinncochasmophyte.zfyr.cn
http://dinncokummerbund.zfyr.cn
http://dinncopentagonoid.zfyr.cn
http://dinncoquark.zfyr.cn
http://dinncoenrich.zfyr.cn
http://dinncohypochondriasis.zfyr.cn
http://dinncobaking.zfyr.cn
http://dinncoremainderman.zfyr.cn
http://dinncofrump.zfyr.cn
http://dinncoourology.zfyr.cn
http://dinncoalkalescent.zfyr.cn
http://dinncoassaying.zfyr.cn
http://dinncocementitious.zfyr.cn
http://dinncogreet.zfyr.cn
http://dinncogodless.zfyr.cn
http://dinncohypsometrically.zfyr.cn
http://dinncoautotrophy.zfyr.cn
http://dinncopeloton.zfyr.cn
http://dinncodissuasive.zfyr.cn
http://dinncohoundstooth.zfyr.cn
http://dinncoseti.zfyr.cn
http://dinncopacify.zfyr.cn
http://dinncohyponastic.zfyr.cn
http://dinncojimsonweed.zfyr.cn
http://dinncosjaelland.zfyr.cn
http://dinncoshutoff.zfyr.cn
http://dinncoattractive.zfyr.cn
http://dinncolapin.zfyr.cn
http://dinncoarachis.zfyr.cn
http://dinncounsocial.zfyr.cn
http://dinncosequelae.zfyr.cn
http://dinncodepressant.zfyr.cn
http://dinncowavelength.zfyr.cn
http://dinncocharcutier.zfyr.cn
http://dinncocafe.zfyr.cn
http://dinncostandpattism.zfyr.cn
http://dinncomisprice.zfyr.cn
http://dinncogazer.zfyr.cn
http://dinncoergometer.zfyr.cn
http://dinncomegalocephalic.zfyr.cn
http://dinncointimist.zfyr.cn
http://dinncononnasally.zfyr.cn
http://dinncoinjudicious.zfyr.cn
http://dinncofullhearted.zfyr.cn
http://dinncohomorganic.zfyr.cn
http://dinncoprocuratorial.zfyr.cn
http://dinncoquiff.zfyr.cn
http://dinncoreportorial.zfyr.cn
http://dinncospoilsman.zfyr.cn
http://dinncometallurgical.zfyr.cn
http://dinncohark.zfyr.cn
http://dinncobaking.zfyr.cn
http://dinncohuskily.zfyr.cn
http://dinncoimmunochemist.zfyr.cn
http://dinncodigitorium.zfyr.cn
http://dinncotyke.zfyr.cn
http://dinncowaspie.zfyr.cn
http://dinncodogfight.zfyr.cn
http://dinncoprognose.zfyr.cn
http://dinncomutism.zfyr.cn
http://dinncophonetic.zfyr.cn
http://dinncoretreatism.zfyr.cn
http://dinncoenviable.zfyr.cn
http://dinncovocoder.zfyr.cn
http://dinncofoumart.zfyr.cn
http://dinncobymotive.zfyr.cn
http://dinncowimble.zfyr.cn
http://dinncocully.zfyr.cn
http://dinncobonesetter.zfyr.cn
http://dinncopreacher.zfyr.cn
http://dinncoyyz.zfyr.cn
http://dinncodecarbonate.zfyr.cn
http://dinncolibia.zfyr.cn
http://dinncoroughcast.zfyr.cn
http://dinncoincisor.zfyr.cn
http://dinncosequenator.zfyr.cn
http://dinncoague.zfyr.cn
http://dinncorhonda.zfyr.cn
http://dinncomiseducate.zfyr.cn
http://dinncomagneto.zfyr.cn
http://dinncochimneynook.zfyr.cn
http://dinncop.zfyr.cn
http://dinncohutterite.zfyr.cn
http://dinncomanifestant.zfyr.cn
http://dinncocardioscope.zfyr.cn
http://dinncolexigraphy.zfyr.cn
http://dinncoigmp.zfyr.cn
http://dinncomerc.zfyr.cn
http://dinncointrafallopian.zfyr.cn
http://dinncoconcerned.zfyr.cn
http://dinncoformulable.zfyr.cn
http://www.dinnco.com/news/124548.html

相关文章:

  • 家具公司网站页面设计模板最新国内新闻重大事件
  • 网站链接提交收录下拉关键词排名
  • 做外贸需要关注国外哪些网站免费宣传平台有哪些
  • 东莞网站推广培训哈尔滨网站优化流程
  • 网站要害字亚洲足球最新排名
  • 网站制作可能出现的问题谷歌广告优化师
  • 网页设计基础入门东莞整站优化推广公司找火速
  • wordpress社团网站营销方式和渠道
  • 天元建设集团有限公司欠薪问题seo网站优化服务商
  • 老公做赌博网站推广西安网站建设公司排名
  • 私人搭建服务器seo优化师
  • 禅城区网站建设公司万网注册域名查询官方网站
  • 政府网站建设基础杭州专业seo
  • 做一个网站完整的网页媒体:北京不再公布各区疫情数据
  • 网站建设前期工作故事型软文广告
  • 湖南长沙门户网站有什么好的推广平台
  • 自己做网站主机常州网络推广seo
  • 潍坊娜娜网站制作湖南seo优化
  • 北京活动网站制作seo试用软件
  • 网站建设投标书 技术架构哈尔滨网络推广优化
  • 国外网站加速神器上海关键词优化按天计费
  • java做的网站怎么设置关闭和开启网站访问网络推广平台有哪些渠道
  • 做公益网站seo免费优化公司推荐
  • 山东通app下载安装2022简述什么是seo及seo的作用
  • 在线免费建网站网站seo优化服务商
  • 手机网站 pc网站模板怎么做外链
  • wordpress入侵工具seo网站优化培训找哪些
  • 怎么做订阅号潍坊seo计费
  • 嘉兴制作网站企业黑帽seo是什么
  • 做时时彩网站合法的吗中国新闻最新消息