分享
分销 收藏 举报 申诉 / 47
播放页_导航下方通栏广告

类型junit基础学习市公开课一等奖省赛课微课金奖课件.pptx

  • 上传人:人****来
  • 文档编号:12616083
  • 上传时间:2025-11-11
  • 格式:PPTX
  • 页数:47
  • 大小:1.29MB
  • 下载积分:12 金币
  • 播放页_非在线预览资源立即下载上方广告
    配套讲稿:

    如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。

    特殊限制:

    部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。

    关 键  词:
    junit 基础 学习 公开 一等奖 省赛课微课 金奖 课件
    资源描述:
    单击此处编辑母版标题样式,单击此处编辑母版文本样式,第二级,第三级,第四级,第五级,2021/10/3,#,JUnit 介绍,Testing framework written by Erich Gamma and Kent Beck,Open Source,Hosted on SourceForge,Language support,Smalltalk,Java,C+,Perl,Python,etc.,IDE Support,JBuilder,VisualAge,etc.,1/47,What is Software Testing?,The execution of code using combinations of,input,and,state,selected to,reveal bugs,.,The process of devising and executing a,test suite,that attempts to,cause failures,increasing our,confidence,that failures are unlikely.,2/47,软件测试工具分类,分,类,实例,reviews&inspections,Compuware DevPartner,test planning,Rational Suite TestStudio,test design&development,test execution&evaluation,capture/playback,coverage analysis,Compuware DevPartner,Rational Suite TestStudio,Borland Optimizeit,memory testing,Compuware DevPartner,Rational Suite TestStudio,test case management,sumulations&performance,profiler,test support,3/47,JUnit 定位,JUnit is,JUnit is not,scope,单元测试,综合测试,组合测试,testware,模块,完整系统,level,工具,方法,轮,test case,手动产生,自,动产生,test driver/script,部份手,写,全自,动,4/47,JUnit Framework,5/47,junit,How to Test with JUnit?,Foo,TestCase,exercise,1.*,TestRunner,run,1.*,FooTest,test,1,test,2,6/47,Questions,怎样,测试?strategy,多少测试才够?coverage,流程?process,工具影响?,medium is message,7/47,Design Goals of JUnit,Easy to use,Requires no more work than absolutely necessary to write a new test,Leverages existing tests to create new ones,Reusable fixtures to run different tests,Retains values of tests over time,Combines tests from various authors and run them together without fear of interference,8/47,Case Study,自动产生测试框架,Using Borland JBuilder 6.0,最,简单测试实例,9/47,实例一,Foo,junit,TestCase,exercise,1.*,FooTest,test,1,test,2,10/47,实例一:简单待测程序,public class,Money,private int fAmount;,private String fCurrency;,public,Money,(int amount,String currency),fAmount=amount;,fCurrency=currency;,public Money,add,(Money m),return new Money(amount()+m.amount(),currency();,public int,amount,()return fAmount;,public String,currency,()return fCurrency;,11/47,实例一:产生测试框架,1/7,Borland JBuilder 6.0,12/47,实例一:产生测试框架,2/7,Borland JBuilder 6.0,13/47,实例一:产生测试框架,3/7,Borland JBuilder 6.0,14/47,实例一:产生测试框架,4/7,Borland JBuilder 6.0,15/47,实例一:产生测试框架,5/7,Borland JBuilder 6.0,16/47,实例一:产生测试框架,6/7,Borland JBuilder 6.0,17/47,实例一:产生测试框架,7/7,import junit.framework.*;,public class,MoneyTest,extends,TestCase,public,MoneyTest,(String s)super(s);,protected void,setUp,(),protected void,tearDown,(),public void,testAdd,(),int val1=0;,String val2=STRING0;,Money money=new Money(val1,val2);,Money val1=null,/*todo fill in non-null value*/,;,Money moneyRet=money.add(val1);,/*todo:Insert test code here.,Use assertEquals(),for example.*/,18/47,Lesson Learned,Code a little,test a little,19/47,junit,实例二,Foo,TestCase,exercise,1.*,TestRunner,run,FooTest,test,1,test,2,20/47,实例二:测试码,public class,Money,implements Cloneable,private int fAmount;,private String fCurrency;,public,Money,(int amount,String currency)/*.*/,public Money,add,(Money m),if(m=null)return(Money)clone();,return new Money(amount()+m.amount(),currency();,public Object,clone,()/*.*/,public boolean,equals,(Object obj)/*.*/,public int,amount,()/*.*/,public String,currency,()/*.*/,21/47,实例二:测试码,1/2,import junit.framework.*;,public class,MoneyTest,extends,TestCase,public,MoneyTest,(String s)super(s);,public void,testNullAdd,(),String curr=NTD;,int val1=;,Money money1=new Money(val1,curr);,Money money2=null;,/null value,Money money3=money1.add(money2);,Assert.assertEquals(money1,money3);,22/47,实例二:测试码,2/2,public void,testSimpleAdd,(),String curr=NTD;,int val1=;,int val2=345;,int val3=val1+val2;,Money money1=new Money(val1,curr);,Money money2=new Money(val2,curr);,Money money3=money1.add(money2);,assertEquals(money3,new Money(val3,curr);,23/47,java -cp,lib,junit.jar;.junit.swingui.TestRunner MoneyTest,Success,24/47,Failure,1/2,25/47,Failure,2/2,26/47,Error,1/2,27/47,Error,2/2,28/47,Lessons Learned,Generate&exercise test case(s),Write,test,(),method(s),Verify,Choose a,Assert.assert,(),Choose a,TestRunner,junit.textui.TestRunner,junit.swingui.TestRunner,Failure vs.error,29/47,Case Study,Fixture/context 管理,Test suite,与进入点,Grouping by tasks,Configuration management,Regression testing,30/47,junit,实例三:,Foo,TestCase,exercise,1.*,TestRunner,run,1.*,FooTest,test,1,test,2,setUp,(),tearDown,(),31/47,实例三:测试码,1/2,import junit.framework.*;,public class,MoneyTest,extends,TestCase,private Money money1,money2,money3;,public,MoneyTest,(String s)/*.*/,protected void,setUp,(),String curr=NTD;,int val1=;,int val2=345;,money1=new Money(val1,curr);,money2=new Money(val2,curr);,money3=new Money(val1+val2,curr);,32/47,实例三:测试码,2/2,protected void,tearDown,(),public void,testNullAdd,(),Money money10=money1.add(null);,/null value,assertEquals(money1,money10);,public void,testSimpleAdd,(),Money money10=money1.add(money2);,assertEquals(money3,money10);,33/47,Lessons Learned,Fixture,Overrides,setUp(),Overrides,tearDown(),Each,test(),method is isolated,34/47,junit,实例四,Foo,TestCase,exercise,1.*,TestRunner,run,1.*,FooTest,test,1,test,2,test case,TestSuite,test suite,35/47,实例四:测试码,1/3,import junit.framework.*;,public class,MoneyTest,extends,TestCase,private Money money1,money2,money3;,public,MoneyTest,(String s)/*.*/,protected void,setUp,()/*.*/,public void,testNullAdd,()/*.*/,public void,testSimpleAdd,()/*.*/,36/47,实例四:测试码,2/3,/interactive mode,/entry point of the whole test suite!,/*,/Version 1,public static Test,suite(),TestSuite,suite=new TestSuite();,suite.,addTest,(new MoneyTest(testNullAdd);,suite.,addTest,(new MoneyTest(testSimpleAdd);,return suite;,*/,/Version 2,public static Test,suite,(),return new,TestSuite,(MoneyTest.class);,37/47,实例四:测试码,3/3,/batch mode,/entry point of the whole test suite!,public static void,main(String args),junit.textui.TestRunner.run(suite();,38/47,Lessons Learned,Test case suite,Write a,suite(),as the interactive mode entry point,Write a,main(),as the batch mode entry point,39/47,实例五:Composite Pattern,40/47,实例五:before grouping,Foo,test suite,exercise,FooTest,test,1,test,2,test,3,test case,41/47,实例五:grouping by tasks,Foo,exercise,FooTest,basic test,test,1,test,2,test suite,random test,test,3,monkey test,stress test,42/47,实例五:composite test suites,public class,Money_test,extends TestCase,public,MoneyTest,(String s)/*.*/,public static Test,suite,(),TestSuite suite=new TestSuite();,suite.addTest(,Money_test_basic.suite(),);,suite.addTest(,Money_test_random.suite(),);,suite.addTest(,Money_test_monkey.suite(),);,return suite;,public static void,main,(String args),junit.textui.TestRunner.run(suite();,43/47,44/47,Lessons Learned,Grouping by configuration policy,By tasks,By persons,By revisions,Configuration management,Naming scheme,Process,Scripts,45/47,小结:JUnit 使用四部曲,Fixture,Overrides,setUp(),or,tearDown(),Exercise,Writes,test(),Verify,Uses,Assert.assert,(),Suite management,Writes,suite(),and/or,main(),46/47,其它主題,Reports,TestResult,Extensions for various application domains,47/47,
    展开阅读全文
    提示  咨信网温馨提示:
    1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
    2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
    3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
    4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
    5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
    6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:0574-28810668;投诉电话:18658249818。

    开通VIP折扣优惠下载文档

    自信AI创作助手
    关于本文
    本文标题:junit基础学习市公开课一等奖省赛课微课金奖课件.pptx
    链接地址:https://www.zixin.com.cn/doc/12616083.html
    页脚通栏广告

    Copyright ©2010-2025   All Rights Reserved  宁波自信网络信息技术有限公司 版权所有   |  客服电话:0574-28810668    微信客服:咨信网客服    投诉电话:18658249818   

    违法和不良信息举报邮箱:help@zixin.com.cn    文档合作和网站合作邮箱:fuwu@zixin.com.cn    意见反馈和侵权处理邮箱:1219186828@qq.com   | 证照中心

    12321jubao.png12321网络举报中心 电话:010-12321  jubao.png中国互联网举报中心 电话:12377   gongan.png浙公网安备33021202000488号  icp.png浙ICP备2021020529号-1 浙B2-20240490   


    关注我们 :微信公众号  抖音  微博  LOFTER               

    自信网络  |  ZixinNetwork