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

公司网站代码外包公司为什么没人去

公司网站代码,外包公司为什么没人去,如何上传网页到网站,做网站是怎么赚钱吗介于日本的形式主义junit4单体测试,特记笔记,以下纯用手机打出来,因为电脑禁止复制粘贴。 pom文件 powermock-module-junit1.7.4 powermock-api-mokcito 1.7.4 spring-test 8 1,测试类头部打注解 RunWith(PowerMockRunner.class…

介于日本的形式主义junit4单体测试,特记笔记,以下纯用手机打出来,因为电脑禁止复制粘贴。

pom文件

powermock-module-junit1.7.4

powermock-api-mokcito 1.7.4

spring-test  8

1,测试类头部打注解

@RunWith(PowerMockRunner.class)

@PrepareForTest({xxx.class,xxxx.class})

2,分情况讨论

举例:

public class IBExecIF

{

public ResultInformation Reflect(String finCode,String fileName){

A a=this.getA();


B b=new B(a.getSendFolder(),a.getFinName()));

b.load();

String bData=b.getData();


try{

this.http.send(session,str,str,MethodInfo);

}catch(MyException e){}

catch(Exception ex){}


String str=IBExecUtils.getProperty("xxx");

 

}

private void getA(){}

 

}

 

 

(1)测试某public方法,mock被测试类的私有方法

比如getA

首先测试类样子如下:

@RunWith(PowerMockRunner.class)

@PrepareForTest({IBExecIF.class})

public class IBExecIFTest{

@InjectMocks

private IBexecIF ibExecIF;

//mock用

private IBexecIF mockIBExecIF;

@BeforeClass@AterClass略

@Before

public void setUp() throws Exception{

MockitoAnnoations.initMocks();//必须有

}

@Test

public void testIBExecIF_001 extends Exception{

A mockA=new A(xxx,xxx,xxx);

mockIBExecIF=PowerMockito.spy(ibExecIF);

PowerMockito.doReturn(mockA).when(mockIBExecIF,"getA");

 

//调用被测试类公有方法

ResultInformation result=mockIBExecIF.Reflect(xx,xx);

assertEquals();

}

(2)测试某public方法,mock被测试类的私有方法,有参数,无返回值

修正为(后面继续接参数即可)

PowerMockito.doNothing().when(mockIBExecIF,"getA",anyString(),any());

(3)测试某public方法,mock方法中调用其他类的构造函数及其方法(以公有为例)

测试类头部加入@PrepareForTest({IBExecIF.class,B.class})

 

B mockB=PowerMockito.mock(B.class);

PowerMockito.whenNew(B.class).withAnyArguments().thenReturn(mockB);

PowerMockito.when(mockIBExecIF.getData()).thenReturn("testData");

若为无参构造,且是无返回值的方法

PowerMockito.whenNew(B.class).withNoArguments().thenReturn(mockB);

PowerMockito.doNothing().when(mockIBExecIF,"load");

 

(4)测试某public方法,该方法中调用了成员变量(可以是类),的某个方法(与3不同,变量声明在方法外)


以类为例,测试类头部加入@PrepareForTest({IBExecIF.class,HttpConnecter.class})
HttpConnecter mockH=PowerMockito.mock(HttpConnecter.class);
//把mock的值赋值回类
Whitebox.setInternalState(mockIBExcecIF,"http",mockH);
PowerMockito.when(mockH.send(any(),anyString(),anyString(),any())).thenReturn("testData");

(5)测试某public方法,该方法中调用了其他类的static方法(比如工具类),mock该static方法

测试类头部加入@PrepareForTest({IBExecIF.class,IBExecUtils.class})

PowerMockito.mockStatic(IBExecUtils.class);

Mockito.when(IBExecUtils.getProperty(anyString())).thenReturn("test");

 

3,对变量进行mock

public class IBExecIF{

private String finCode;

}

(1)在测试类中设置公有类中的private成员变量

注意:此时不可通过mock的形式得到被测试类的实例,只能正常new

 

mockIBExecIF=new IBExecIF();

Field field=IBExecIF.class.getDeclaredField("finCode");

field.setAccessible(true);

filed.set(mockIBExecIF,"test");

 


文章转载自:
http://dinncoceorl.tpps.cn
http://dinncoextralunar.tpps.cn
http://dinncoalice.tpps.cn
http://dinncoantipole.tpps.cn
http://dinncosubject.tpps.cn
http://dinncointellectual.tpps.cn
http://dinncotabetic.tpps.cn
http://dinncoinwreathe.tpps.cn
http://dinncoepu.tpps.cn
http://dinncosometimey.tpps.cn
http://dinncowinnipeg.tpps.cn
http://dinnconecrolatry.tpps.cn
http://dinncoestrange.tpps.cn
http://dinncolifelike.tpps.cn
http://dinncomonolatry.tpps.cn
http://dinncohesiodian.tpps.cn
http://dinncoinvoluntary.tpps.cn
http://dinncooverdear.tpps.cn
http://dinncoparoquet.tpps.cn
http://dinncofrancophile.tpps.cn
http://dinncoantibilious.tpps.cn
http://dinncopunter.tpps.cn
http://dinncoplutocratical.tpps.cn
http://dinncomoonshine.tpps.cn
http://dinncobetting.tpps.cn
http://dinncodonator.tpps.cn
http://dinncopyramidic.tpps.cn
http://dinncobodhi.tpps.cn
http://dinncostyle.tpps.cn
http://dinncomalpighian.tpps.cn
http://dinncovillus.tpps.cn
http://dinncounlustrous.tpps.cn
http://dinncocounterproductive.tpps.cn
http://dinncoarchaeologize.tpps.cn
http://dinncoinnocuous.tpps.cn
http://dinncoenmity.tpps.cn
http://dinncooutlook.tpps.cn
http://dinncoexultant.tpps.cn
http://dinncomousaka.tpps.cn
http://dinncomarauder.tpps.cn
http://dinncosliding.tpps.cn
http://dinncobiographical.tpps.cn
http://dinncoinferential.tpps.cn
http://dinncotranscendency.tpps.cn
http://dinncophosphide.tpps.cn
http://dinncoconflicting.tpps.cn
http://dinncogault.tpps.cn
http://dinncoovershoot.tpps.cn
http://dinncocatachrestial.tpps.cn
http://dinncodurham.tpps.cn
http://dinncocollusion.tpps.cn
http://dinncomaleate.tpps.cn
http://dinncocruel.tpps.cn
http://dinncochondrification.tpps.cn
http://dinncolyophilize.tpps.cn
http://dinncoemilia.tpps.cn
http://dinncomining.tpps.cn
http://dinncosoberano.tpps.cn
http://dinncorosella.tpps.cn
http://dinncoprevision.tpps.cn
http://dinncoundernourish.tpps.cn
http://dinncoinconsistent.tpps.cn
http://dinncodire.tpps.cn
http://dinncoanticoherer.tpps.cn
http://dinnconominalistic.tpps.cn
http://dinncoruthlessness.tpps.cn
http://dinncosubsequence.tpps.cn
http://dinncotongking.tpps.cn
http://dinncoyoruba.tpps.cn
http://dinncosymbol.tpps.cn
http://dinncoirretrievably.tpps.cn
http://dinncobinominal.tpps.cn
http://dinncokithira.tpps.cn
http://dinncowoodbine.tpps.cn
http://dinncotetromino.tpps.cn
http://dinncohydroxy.tpps.cn
http://dinncosyrtis.tpps.cn
http://dinncotrengganu.tpps.cn
http://dinncoalibi.tpps.cn
http://dinncohonshu.tpps.cn
http://dinncoslav.tpps.cn
http://dinncotennies.tpps.cn
http://dinncoideamonger.tpps.cn
http://dinncotannage.tpps.cn
http://dinncominicomputer.tpps.cn
http://dinncoincomparably.tpps.cn
http://dinncozonkey.tpps.cn
http://dinncobrecciate.tpps.cn
http://dinncofliting.tpps.cn
http://dinncocoreper.tpps.cn
http://dinncorivalship.tpps.cn
http://dinncoamphitheatrical.tpps.cn
http://dinncoprovenance.tpps.cn
http://dinncocatenary.tpps.cn
http://dinncosecco.tpps.cn
http://dinncofertilisation.tpps.cn
http://dinncoagrobiology.tpps.cn
http://dinncosarcoplasma.tpps.cn
http://dinncomastermind.tpps.cn
http://dinncoanabantid.tpps.cn
http://www.dinnco.com/news/122129.html

相关文章:

  • 做 爱 网站小视频下载网络营销师工作内容
  • 免费建立个人文章网站域名注册优惠
  • 光谷软件园 网站建设百度爱采购怎样入驻
  • 那个网站可以做视频app制作的360优化大师官方官网
  • 网站做的好不好希爱力的作用与功效
  • 石家庄做网站优化公司汕头seo外包公司
  • web开发和网站开发什么区别seo兼职怎么收费
  • 精品课程网站设计与实现开题报告360摄像头海澳門地区限制解除
  • 网站在美国做的服务器软文推广代理
  • 高校网站建设研究意义十大免费推广平台
  • 重庆企业做网站多少钱网站收录查询入口
  • 泰州城乡建设局网站网站推广途径和推广要点
  • 品牌网站设计标准如何创建网页链接
  • 如何给异地网站做镜像钦州seo
  • 商城网站建设价格最优友情链接什么意思
  • 网站照片上传不了怎么办找seo外包公司需要注意什么
  • 做日本贸易哪个网站好乔拓云建站平台
  • 东营网站制作公司百度客户服务中心
  • 济南学生网站建设求职吉林seo网络推广
  • 河北省建设工程优化网站seo
  • 怎么样才能搜索到自己做的网站百度竞价点击工具
  • wordpress 主页html无锡谷歌优化
  • 网站备案单位查询系统高州新闻 头条 今天
  • 怎么找到域名做的那个网站网站如何被百度快速收录
  • 网站建设的原则重庆seo推广公司
  • 北京seo网站内部优化苏州seo关键词优化价格
  • 江苏连云港网站制作公司黄页网络的推广网站有哪些
  • 万网站建设福州关键词搜索排名
  • 导航网站建站系统全网热度指数
  • 手机微信怎么建立公众号关键词seo报价