Skip to content

Running Unit tests

Damien Picard edited this page Apr 25, 2017 · 15 revisions

IDEAS Unit tests

This topic explains how to run the IDEAS unit tests. The instructions work on Linux and on Windows.

Download BuildingsPy:

First you need to download BuildingsPy from https://github.com/lbl-srg/BuildingsPy:

git clone https://github.com/lbl-srg/BuildingsPy.git

Install BuildingsPy:

This package needs to be built and installed. Open terminal in the just downloaded BuildingsPy directory and execute in Linux:

python setup.py build
sudo python setup.py install

In Windows, make sure you have the administrator rights and execute:

python setup.py build
python setup.py install

BuildingsPy is now installed. However, the unit tests use tidylib which needs to be installed manually. Its installation is described here. It is normally enough to download the tidylib.dll and save it in a folder contained in your system path.

Check Dymola settings

Before you run unittests, it's best to check if you are using the right settings. Otherwise, the unit tests may fail and yield strange errors.

  • Check if you can open Dymola from the command line. This is done by typing dymola and pressing enter.
  • If Dymola does not start, add the installation directory (for Windows: C:\Program Files (x86)\Dymola 201x\bin64) to your system path
  • If Dymola starts but loads predefined packages, change these settings in the setup.mos file (you can find it under C:\Users\username\AppData\Roaming\Dynasim). There should be no openModel() commands.

This should suffise to run unit tests.

Run Unit test:

Open the file IDEAS/IDEAS/RunUnitTests.py and make sure you use the desired number of processors by adapting tester.setNumberOfThreads(4). By default the file uses 4 processors. The unit tests can be run by opening terminal in the IDEAS root directory and executing the following commands:

cd IDEAS/IDEAS
python RunUnitTests.py

The unit tests may not run if you do not have TidyLib installed. Since installing this can be quite cumbersome it is easier to disable the HTML checking functionality by replacing ut = u.Tester(check_html=True) by ut = u.Tester(check_html=False) in runUnitTest.py. This only determines whether the HTML syntax of the model info is checked or not.

Notice that you can also run only the unittests contained in one package using the function ut.setSinglePackage('MyLibrary.MyModel').

In case of errors

It is however possible that you still get error messages (such as .mat files that cannot be found, simulations that fail for RunScript("... .mos");). In this case, it can be that there is no compiler specified for Dymola yet. Check if the setup.mos file contains a SetDymolaCompiler() command. If not:

  • Open Dymola, set the compiler again
  • Open the setup.mos file (see above for location)
  • Check that there is a SetDymolaCompiler() command now
Clone this wiki locally