A simple and practical approach to unit testing: The JML and JUnit way

被引:0
|
作者
Cheon, Y [1 ]
Leavens, GT [1 ]
机构
[1] Iowa State Univ Sci & Technol, Dept Comp Sci, Ames, IA 50011 USA
来源
关键词
D O I
暂无
中图分类号
TP301 [理论、方法];
学科分类号
081202 ;
摘要
Writing unit test code is labor-intensive, hence it is often not done as an integral part of programming. However, unit testing is a practical approach to increasing the correctness and quality of software; for example, the Extreme Programming approach relies on frequent unit testing. In this paper we present a new approach that makes writing unit tests easier. It uses a formal specification language's runtime assertion checker to decide whether methods are working correctly, thus automating the writing of unit test oracles. These oracles can be easily combined with hand-written test data. Instead of writing testing code, the programmer writes formal specifications (e.g., pre- and postconditions). This makes the programmer's task easier, because specifications are more concise and abstract than the equivalent test code, and hence more readable and maintainable. Furthermore, by using specifications in testing, specification errors are quickly discovered, so the specifications are more likely to provide useful documentation and inputs to other tools. We have implemented this idea using the Java Modeling Language (JML) and the JUnit testing framework, but the approach could be easily implemented with other combinations of formal specification languages and unit test tools.
引用
收藏
页码:231 / 255
页数:25
相关论文
共 50 条
  • [21] A practical approach to testing GUI systems
    Li, Ping
    Huynh, Toan
    Reformat, Marek
    Miller, James
    [J]. EMPIRICAL SOFTWARE ENGINEERING, 2007, 12 (04) : 331 - 357
  • [22] Nanofibers - a Simple and Practical Way Forward for Air Pollution Abatement
    Shahzad, Naeem
    Chen, Qiao
    [J]. ISESCO CONFERENCE ON NANOMATERIALS AND APPLICATIONS 2012, 2013, 756 : 225 - +
  • [23] Voice Internet - A simple and Practical Way To Provide Internet to Everyone
    Khan, Emdad
    [J]. CHALLENGES FOR ASSISTIVE TECHNOLOGY, 2007, 20 : 271 - 275
  • [24] A PRACTICAL APPROACH TO A MOBILE CORONARY CARE UNIT
    CALLEN, IR
    LEBAR, YY
    WAGNER, PI
    RIERA, R
    DREHER, D
    [J]. CIRCULATION, 1970, 42 (04) : I141 - &
  • [25] Consider a practical approach to vacuum unit revamps
    Zeidan, A
    [J]. HYDROCARBON PROCESSING, 2006, 85 (01): : 73 - +
  • [26] Practical Approach for Electron Monitor Unit Calculation
    Choi, D.
    [J]. MEDICAL PHYSICS, 2008, 35 (06)
  • [27] Unconsciousness in the Intensive Care Unit: A Practical Approach
    Hakimi, Ryan
    McDonagh, David L.
    [J]. INTERNATIONAL ANESTHESIOLOGY CLINICS, 2008, 46 (03) : 171 - 193
  • [28] A practical approach for electron monitor unit calculation
    Choi, David
    Patyal, Baldev
    Cho, Jongmin
    Cheng, Ing Y.
    Nookala, Prashanth
    [J]. PHYSICS IN MEDICINE AND BIOLOGY, 2009, 54 (16): : N367 - N374
  • [29] A New Approach to Unit Root Testing
    Herwartz, Helmut
    Siedenburg, Florian
    [J]. COMPUTATIONAL ECONOMICS, 2010, 36 (04) : 365 - 384
  • [30] A New Approach to Unit Root Testing
    Helmut Herwartz
    Florian Siedenburg
    [J]. Computational Economics, 2010, 36 : 365 - 384