Testing is software

Testing is software

Test early, test often, test against requirements and test using formal methods. This is the mantra that developers (hopefully) hear. But what does it mean in practice? How do you produce effective and maintainable tests? I will argue that the first step is to think of test development in the same light as software development. Good testing infrastructure has requirements, is built from reusable components and written in a clear fashion to facilitate extensions and debugging efforts.

Why should you care?

In my 20+ years working in software, 2/3 of it in a consultative role, the most common problem I am called in to work on is mushroom code(1). Mushroom code is the end result of unstructured development, new algorithms are added on top of existing algorithms with little understanding of what it is feeding on. The result is an organic mess that is hard to sort out. This is prevalent in algorithmic development and even more common in testing which is often done "late and under the gun"

Testing components

A fully developed testing infrastructure consists of 5 components, a manager, execution methods, harnesses, reporting methods, and evaluation methods.

1.) Evaluation methods: use the data created through the execution of the test to determine the pass / fail / percentage complete status of the test:

Example a.) A MCDC test the evaluation would determine the percentage of conditions taken

Example b.) A regression test could compare the output values of between the baseline version of the code and the current release.

2.) Reporting methods: take the data from the evaluation methods and generate both human readable and history reports. The history reports are used to track overall trends in the software development process.(2)

3.) Harness: the harness provides a method for calling the unit under test (UUT) without modifying the UUT. Note test harnesses facilitate black box testing, e.g. the internal states of the unit under test are not known. However if internal states of the UUT are outputs at the root level of the model then white box testing can be done using the unit under test.(3)

4.) Execution methods: is how the test is run. This could be the simulation of a Simulink model, the execution of a .exe file, static testing (as with Polyspace) or the Real-Time execution (4)of the code.

As the name implies there is more than one "execution method." They should be developed as a general class that allows the same method (simulation) to be applied to multiple harnesses. Each instance of a execution method applied to a harness is considered a test case.

5.) Test manager: is were all of these components come together. The test manager

  • Holds a list of the test cases
  • Automates the loading of associated test data
  • Triggers the execution of the test
  • Triggers the evaluation of the results
  • Triggers the generate of the test report

Sadly it will not yet fetch you a cold beverage.

Notes

1.) Mushroom code and spaghetti code are similar that they develop due to a lack of planning. Spaghetti code is characterized with convoluted calling structures; mushroom code is accumulation of code on top of code.

2.) An interesting list of what should go into a report can be found here.

3.) Any model can be turned into white box testing if global data is used. However the use of global data potential introduces additional failure cases.

4.) Yes, this blog retreads the work from 6 months ago, however it is good to review these issues.


BIO

Michael Burke is a consultant with The MathWorks and former coordinator for the MathWorks Automotive Advisory Board (MAAB). I currently focus on Model-Based Design Process Adoption and Establishment projects. Views expressed in this article do not represent the views of The MathWorks.


要查看或添加评论,请登录

Michael Burke的更多文章

  • 0x7E0: The year in review

    0x7E0: The year in review

    As 2016 winds down journalistic standards require a top N list. So while the points in my list are non-NULL I shall…

  • Behind the M.A.A.B. Style Guide: Lessons in working with brilliant people

    Behind the M.A.A.B. Style Guide: Lessons in working with brilliant people

    For 8 years, between 2005 and 2013, I had the privilege of hosting the MathWorks Automotive Advisory Board (MAAB). In…

  • If brevity is the soul of wit...

    If brevity is the soul of wit...

    Than clarity is the heart of development. Projects begin with a requirement, often vague and frequently unrealistic(1).

  • The Fault in Our Stars (e.g. systems)

    The Fault in Our Stars (e.g. systems)

    We all have our faults(1), for me it is telling an excessive(2) number of puns. Knowing that this is one of my fault…

  • Software Best Practices: Version Control

    Software Best Practices: Version Control

    A few days ago, at the start of my work day, my laptop refused to boot up. Having just got off the road my first…

    3 条评论
  • Model-Based Design Process Estabishment

    Model-Based Design Process Estabishment

    This video provides a quick look at how I look at adoption of Model-Based Design practices.

  • Meta-data and Model Based Design

    Meta-data and Model Based Design

    Back in the summer of 2015 I wrote a blog post "A few thoughts on naming conventions" in which I recommended encoding…

  • The house that Model-Based Design Builds

    The house that Model-Based Design Builds

    For the past year I have followed a video blog called "primitive technology" in it the author takes you through…

  • The house that Model-Based Design Builds (preview video)

    The house that Model-Based Design Builds (preview video)

    This video is a preview of the blog that will come out on Monday.

  • What is on your white board?

    What is on your white board?

    In meetings or in your office the humble white board(0) is a rapid prototyping environment through which we communicate…

    2 条评论

社区洞察

其他会员也浏览了