1 / 16

JTester 和 常用插件介绍

JTester 和 常用插件介绍. 吴大瑞 2009-05-12. Agenda. 测试命名规范 MoreUnit Fluent Syntax ( 断言 ) POJO Serialize Wiki 方式准备测试数据 和 martini 框架集成的初步设想 代码覆盖工具. 测试命名规范. 业务代码和测试代码放在同一个工程下 业务代码和测试代码路径要区分开 业务类和测试类 package 最好一样 测试类命名 (业务类 1:N 测试类) BizClazTest BizClaxTest_Spec 测试方法命名 (业务方法 1:N 测试方法)

skylar
Download Presentation

JTester 和 常用插件介绍

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JTester 和常用插件介绍 吴大瑞 2009-05-12

  2. Agenda • 测试命名规范 • MoreUnit • Fluent Syntax (断言) • POJO Serialize • Wiki方式准备测试数据 • 和martini框架集成的初步设想 • 代码覆盖工具

  3. 测试命名规范 • 业务代码和测试代码放在同一个工程下 • 业务代码和测试代码路径要区分开 • 业务类和测试类package最好一样 • 测试类命名 (业务类 1:N 测试类) • BizClazTest • BizClaxTest_Spec • 测试方法命名 (业务方法 1:N 测试方法) • method • test_method • test_method_spec • test_method1_method2

  4. MoreUnit Plugin • 代码标签装饰 • 创建测试package, class, method • 测试类 跳转 业务类 • 快捷键 ctrl + J 和 ctrl + U • Missing testmethod view • 代码重构支持

  5. MoreUnit Plugin

  6. MoreUnit Plugin • 对命名规格支持的不充分 • 误判 User • UserTest • UserServiceTest • 找不到 • UserTest_NotFound • 希望改进 • 提供一个视图:列出所有测试类,测试方法

  7. Fluent Syntax • Assert Syntax: want.object(value).assert(expected)

  8. Fluent Syntax • JMock Method Expcetd Syntax: will.call.one(service).method(…)

  9. Fluent Syntax • JMock Para Assert: the.object.assert(expected).wanted()

  10. POJO Serialize • 应用场景 • SerializeUtil.toDat(pojo, “?.dat”) • SerializeUtil.toXML(pojo, “?.xml”) • Biz biz = SerializeUtil.fromDat(Biz.class, “?.dat”) • Biz biz = SerializeUtil.fromDat(Biz.class, “?.xml”) • xml vs. dat ?

  11. Wiki方式准备测试数据 • Dbunit xml方式的缺点 • 不直观 • 难编辑 • Wiki dataset • 4种策略

  12. 和martini框架集成的初步设想 • 在工程中建一个commontest • 准备测试第三方jar包 • 准备通用的spring文件 • 准备ibatis的sqlmap文件 • 要测试工程依赖commontest工程 • 准备项目中自己用到的spring文件 • test-java目录 • 需要测试的类? • 难以测试的类? (重构? 不测试?)

  13. 代码覆盖工具EclEmma

  14. Resources • Moreunit http://moreunit.sourceforge.net/ • JTester http://code.google.com/p/java-tester/ • Eclipse Wiki http://eclipsewiki.sourceforge.net/ • EclEmma http://update.eclemma.org/

  15. 结束语 测试的作用不仅仅是测试代码

  16. Q&A Q & A

More Related