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 条
  • [1] JUnit: Unit testing and coding in tandem
    Louridas, P
    [J]. IEEE SOFTWARE, 2005, 22 (04) : 12 - 15
  • [2] The extension of the unit testing tool Junit for special testings
    Kong, Liangliang
    Yin, Zhaolin
    [J]. FIRST INTERNATIONAL MULTI-SYMPOSIUMS ON COMPUTER AND COMPUTATIONAL SCIENCES (IMSCCS 2006), PROCEEDINGS, VOL 2, 2006, : 410 - +
  • [3] Lazy systematic unit testing:JWalk versus JUnit
    Simons, Anthony J. H.
    Thomson, Christopher D.
    [J]. TAIC PART 2007 - TESTING: ACADEMIC AND INDUSTRIAL CONFERENCE - PRACTICE AND RESEARCH TECHNIQUES, PROCEEDINGS: CO-LOCATED WITH MUTATION 2007, 2007, : 138 - 138
  • [4] Simplified Way of Learning White-Box Testing with JUnit
    Sung, Keum-Young
    [J]. ADVANCED MULTIMEDIA AND UBIQUITOUS ENGINEERING: FUTURETECH & MUE, 2016, 393 : 783 - 789
  • [5] JUnit plus plus : An Open Educational Tool for Simplifying Unit Testing
    Adeyemi, Opey
    Adiraju, Abhineeth
    Akins, Seth
    Khademi, Keyvan
    Hui, Bowen
    [J]. 2023 IEEE INTERNATIONAL CONFERENCE ON ADVANCED LEARNING TECHNOLOGIES, ICALT, 2023, : 24 - 25
  • [6] Design and implementation of S2SH unit testing based on JUnit
    Zhang, Zhiming
    Deng, Jiangang
    Jiang, Changgen
    [J]. 2011 SECOND INTERNATIONAL CONFERENCE ON EDUCATION AND SPORTS EDUCATION (ESE 2011), VOL III, 2011, : 493 - 496
  • [7] A semi-automatic generator for unit testing code files based on JUnit
    Huang, CH
    Chen, HY
    [J]. INTERNATIONAL CONFERENCE ON SYSTEMS, MAN AND CYBERNETICS, VOL 1-4, PROCEEDINGS, 2005, : 140 - 145
  • [8] A Practical Way of Testing Security Patterns
    Regainia, Loukmen
    Salva, Sebastien
    [J]. THIRTEENTH INTERNATIONAL CONFERENCE ON SOFTWARE ENGINEERING ADVANCES (ICSEA 2018), 2018, : 7 - 12
  • [9] Complex ATM testing - the simple way
    Arweiler, Hans Werner
    [J]. Telcom Report (English Edition), 1994, 17 (06): : 44 - 45
  • [10] Simple practical testing on solution speeds
    Roth, WA
    [J]. ZEITSCHRIFT FUR ELEKTROCHEMIE UND ANGEWANDTE PHYSIKALISCHE CHEMIE, 1910, 16 : 714 - 716