Child pages
  • matlab test FAQ
Skip to end of metadata
Go to start of metadata

I looked over some codes and structure in the OpenEarth repository, and got a couple questions/concerns/worries. I'd like to share them with you and, hopefully, you already have an answer to them.

Q) Test files. You suggested to add a function.m and function_test.m files into the same folder. I would like to suggest not to include _test files into the same folder with the main function. First, it creates a list of unnecessary files in the toolbox folder. Second, if you use a toolbox, then you probably have it in the path and then you can run test from any folder. Third, test files may require some additional data files, or preprocessing scripts etc. So, why put everything into one pile? Maybe it is better to create a special folder with test files only (even put them into subfolders if needed). The automatic testing routine would go through all subfolders and will run designated test files. Designated test files could be with _test suffix, or something more general as "runtest.m" if that particular folder contains a test for one specific function. That set of tests can be run by anyone to test if the entire collection is working, but not really necessary to do normal work.

A) You are probably right in all aspects you mention. But the most important aspect from your question is that you do not question the fact that each mfile should have an associated test file in the first place. You only question where to put this test file. And the aspect of having a test file in the first place is the most important part of what we try to achieve. Therefore we put the test file between the regular m files, so that people who are not yet test-minded will start to make tests too. An additional advantage of putting test files next to the regular mfiles is that test files are a working code example, and can be considered as an extension of the documentation. Not until the majority of OpenEarth participants actually makes test, can we start to think where to relocate them. Actually we already investigated that, we decided to relocate all test data to another directory to keep the tools collection small ( In addition there is already a testing toolbox (Mtest) that scrolls all directories and filters all _test.m files. This toolbox is part of the OET maintenance tools (
We run this toolbox on a teamcity built server (currently not yet available for non-Deltares participants, but will be in 2011) that also includes all the test data (simple adds all directories to matlab path).

  • No labels