First time here? Check our help page!
4

How to do unit test for OpenStudio in Ubuntu

I download the OpenStudio source code and am studying it for my research. I run the software in Ubuntu. Two questions are bothering me: (1)How to do the unit test?(2) Where is the main function()? I only found a bunch of functions for objects: fans, pump, coil, etc...

building_performance's avatar
441
building_performance
asked 2015-06-30 08:45:34 -0500
__AmirRoth__'s avatar
4.4k
__AmirRoth__
updated 2015-07-26 18:09:45 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

5

OpenStudio C++ development is deep water, but step one is following these directions for setting up your build environment.

You need to make sure you configure with testing enabled.

image description

Once you have a functioning build you can run all of the unit tests with ctest.

cd <openstudio-build-directory>/OSCore-prefix/src/OSCore-build/
ctest

OpenStudio unit tests are implemented using the gtest framework. GTest provides a main function that serves as the test runner. There are several different test runners (test executables) corresponding to different areas of the code. CTest on the other hand is like a meta test runner that wraps a single interface around the entire collection of tests. Using ctest the way I described above is the easiest way to run ALL of the tests, but you can also access the gtest runners directly with something like this for the Model API tests.

./<openstudio-build-directory>/OSCore-prefix/src/OSCore-build/Products/openstudio_model_tests

Here is an example of some of the Model tests.

The ctest and gtest interfaces both take a range of arguments to select specific tests and choose runner options. Use the --help option to see a list of their respective options.

 ctest --help
./<openstudio-build-directory>/OSCore-prefix/src/OSCore-build/Products/openstudio_model_tests --help
Kyle Benne's avatar
6k
Kyle Benne
answered 2015-07-01 10:46:50 -0500, updated 2015-07-01 11:25:00 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments