Abstract
The intricacies of programming demands a precise understanding of a programming language, its libraries and its conventions. Programming education normally does not emphasise this well enough, often leaving technicalities vague and omitting corner cases. In addition, students starting computing studies at university have about 12 years of basic education behind them. The intuition the students bring with them to university is in many ways at odds with the technicalities of programming. This mismatch is later the source of many computer related vulnerabilities and in some cases causes disasters.
Here we advocate axiom based testing as a technique to master these demands. Axiom based testing is based on programming language semantics, not mathematical semantics. There is no need for quantifiers in the specifications, and no need for formal reasoning to achieve the benefits. Using axiom based testing does not presuppose more than the ability to write methods and assertions, a part of any beginning programming course. Thus axiom based testing is a very lightweight formal method. It can be used both to understand other people’s code, e.g., libraries and APIs, and to validate own code. Axiom based testing integrates naturally with unit testing and can be an aid for both students and practitioners in getting the technical details right. Our experience is that axiom based testing can easily be taught at the undergraduate level. It is as fun to use as unit testing, giving the same direct feedback.
This paper contains many hands on examples, mostly in Java. It can be the basis for self studies in axiom based testing for Java or for teaching axiom based testing for any programming language.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
There is of course a problem with the conditional axioms like antisymmetry, where few, if any, of the test values actually will reach the target of the conditional. Quickcheck [6] has special treatment of conditionals in order to generate random data that actually reaches the target.
- 2.
The end of [19] shows additional benefits.
References
Bagge, A.H., David, V., Haveraaen, M.: Testing with axioms in C++ 2011. J. Object Technol. 10, 10:1–10:32 (2011). https://doi.org/10.5381/jot.2011.10.1.a10
Beck, K.: Extreme programming: a humanistic discipline of software development. In: Astesiano, E. (ed.) FASE 1998. LNCS, vol. 1382, pp. 1–6. Springer, Heidelberg (1998). https://doi.org/10.1007/BFb0053579
Beckert, B., Schlager, S.: Refinement and retrenchment for programming language data types. Formal Asp. Comput. 17(4), 423–442 (2005). https://doi.org/10.1007/s00165-005-0073-x
Bergstra, J.A., Tucker, J.: Algebraic specifications of computable and semi-computable data types. Theor. Comput. Sci. 50, 137–181 (1987). https://doi.org/10.1016/0304-3975(87)90123-X
Bloch, J.: Extra, extra - read all about it: Nearly all binary searches and merge sorts are broken. https://ai.googleblog.com/2006/06/extra-extra-read-all-about-it-nearly.html. Accessed 23 July 2020
Claessen, K., Hughes, J.: QuickCheck: a lightweight tool for random testing of Haskell programs. In: ICFP 2000: Proceedings of the Fifth ACM SIGPLAN International Conference on Functional Programming, pp. 268–279. ACM Press, New York, NY, USA (2000). https://doi.org/10.1145/351240.351266
Correctness 2020: Fourth International Workshop on Software Correctness for HPC Applications. https://correctness-workshop.github.io/2020/. Accessed 08 Apr 2020
Dahl, O.J., Myhrhaug, B., Nygaard, K.: SIMULA 67 Common Base Language, Vol. S-2. Norwegian Computing Center, Oslo (1968)
David, V.: Catsfoot (2011). https://catsfoot.sourceforge.net/
Dijkstra, E.W.: Guarded commands, non determinacy and formal derivation of programs. Commun. ACM 18(8), 453–457 (1975). https://doi.org/10.1145/360933.360975
Eclipse. https://www.eclipse.org. Accessed 22 June 2020
Gannon, J.D., McMullin, P.R., Hamlet, R.G.: Data-abstraction implementation, specification, and testing. ACM Trans. Program. Lang. Syst. 3(3), 211–223 (1981). https://doi.org/10.1145/357139.357140
Gopalakrishnan, G., et al.: Report of the HPC correctness summit, Jan 25–26, 2017, Washington, DC. CoRR abs/1705.07478 (2017). https://arxiv.org/abs/1705.07478
Gosling, J., Joy, B., Steele, G., Bracha, G., Buckley, A., Smith, D., Bierman, G.: The Java language specification - Java SE 14 Edition. Technical report. JSR-389 Java SE 14, Oracle America (Feb 2020). https://docs.oracle.com/javase/specs/
Hamlet, R.: Random testing. In: Marciniak, J. (ed.) Encyclopedia of Software Engineering, pp. 970–978. Wiley, Hoboken (1994). https://doi.org/10.1002/0471028959.sof268
Haveraaen, M., Kalleberg, K.T.: JAxT and JDI: the simplicity of JUnit applied to axioms and data invariants. In: OOPSLA Companion 2008: Companion to the 23rd ACM SIGPLAN Conference on Object Oriented Programming Systems Languages and Applications, pp. 731–732. ACM, New York, NY, USA (2008). https://doi.org/10.1145/1449814.1449834
Hoare, C.A.R.: An axiomatic basis for computer programming. Commun. ACM 12(10), 576–583 (1969). https://doi.org/10.1145/363235.363259
Hoare, C.A.R., Wirth, N.: An axiomatic definition of the programming language PASCAL. Acta Inf. 2, 335–355 (1973). https://doi.org/10.1007/BF00289504
Hughes, J.: Quickcheck testing for fun and profit. In: Hanus, M. (ed.) PADL 2007. LNCS, vol. 4354, pp. 1–32. Springer, Heidelberg (2006). https://doi.org/10.1007/978-3-540-69611-7_1
Hughes, J.: Experiences from teaching functional programming at Chalmers. ACM SIGPLAN Notices 43(11), 77–80 (2008). https://doi.org/10.1145/1480828.1480845
ISO/IEC 14882:2017 - Programming languages - C++ (2017). https://www.iso.org/standard/68564.html
ISO/IEC 9899:2018 - Information technology - Programming languages - C (2018). https://www.iso.org/standard/74528.html
Java platform, standard edition & Java development kit - version 14 API specification. https://docs.oracle.com/en/java/javase/14/docs/api/java.base/module-summary.html. Accessed 29 June 2020
Junit 5. https://junit.org/junit5/. Accessed 24 June 2020
Kalleberg, K.T., Haveraaen, M.: JAxT - Java Axiomatic Testing. https://www.ii.uib.no/mouldable/testing/. Accessed 24 June 2020
Liskov, B.: Keynote address - data abstraction and hierarchy. In: Addendum to the Proceedings on Object-Oriented Programming Systems, Languages and Applications (Addendum), pp. 17–34, OOPSLA 1987. Association for Computing Machinery, New York, NY, USA (1987). https://doi.org/10.1145/62138.62141
Meyer, B.: Applying “Design by contract”. Computer 25(10), 40–51 (1992). https://doi.org/10.1109/2.161279
Saff, D.: Theory-infected: or how I learned to stop worrying and love universal quantification. In: OOPSLA 2007: Companion to the 22nd ACM SIGPLAN Conference on Object Oriented Programming Systems and Applications Companion, pp. 846–847. ACM, New York, NY, USA (2007). https://doi.org/10.1145/1297846.1297919
Sannella, D., Tarlecki, A.: Mind the gap! Abstract versus concrete models of specifications. In: Penczek, W., Szałas, A. (eds.) MFCS 1996. LNCS, vol. 1113, pp. 114–134. Springer, Heidelberg (1996). https://doi.org/10.1007/3-540-61550-4_143
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2021 Springer Nature Switzerland AG
About this paper
Cite this paper
Haveraaen, M. (2021). Axiom Based Testing for Fun and Pedagogy. In: Cerone, A., Roggenbach, M. (eds) Formal Methods – Fun for Everybody. FMFun 2019. Communications in Computer and Information Science, vol 1301. Springer, Cham. https://doi.org/10.1007/978-3-030-71374-4_2
Download citation
DOI: https://doi.org/10.1007/978-3-030-71374-4_2
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-71373-7
Online ISBN: 978-3-030-71374-4
eBook Packages: Computer ScienceComputer Science (R0)