Skip to main content Accessibility help
×
Hostname: page-component-8448b6f56d-sxzjt Total loading time: 0 Render date: 2024-04-24T11:43:13.234Z Has data issue: false hasContentIssue false

8 - Unit Testing

Published online by Cambridge University Press:  05 July 2012

Arjen Markus
Affiliation:
Deltares, Delft, The Netherlands
Get access

Summary

The subject of this chapter is a simple framework for automating one particular aspect of testing: unit tests. Unit tests focus on “small” parts of a program, typically single subroutines or functions. The idea is these tests give confidence in the correct operation of routines. As the code for these tests should be considered part of the program, you can repeatedly run them during development and maintenance of the whole system. Some development methods take this to the extreme. Test-driven development (TDD), for instance, prescribes that the tests be written first, before you start implementing the actual code.

This is just one way to develop a program, but thinking about the ways you can test a particular routine helps to define its functionality. Most importantly, however, such unit tests become part of the program. Therefore, testing at that level is not an afterthought, implemented in ad hoc one-off programs.

Testing Frameworks

Junit is a well-known framework for unit tests in a Java programming environment [37]. It has been seminal for a whole range of similar frameworks for all manner, of programming languages. Junit depends on explicit support from several language features that Fortran does not have, such as special annotations and the possibility to programmatically get a list of routine (method) names from a library. Nevertheless, it is quite possible to implement a unit testing framework in Fortran as well.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2012

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Unit Testing
  • Arjen Markus
  • Book: Modern Fortran in Practice
  • Online publication: 05 July 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9781139084796.010
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Unit Testing
  • Arjen Markus
  • Book: Modern Fortran in Practice
  • Online publication: 05 July 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9781139084796.010
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Unit Testing
  • Arjen Markus
  • Book: Modern Fortran in Practice
  • Online publication: 05 July 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9781139084796.010
Available formats
×