Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

Revision history [back]

OpenStudio C++ development is deep water, but step one is following these directions for setting up you 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

OpenStudio C++ development is deep water, but step one is following these directions for setting up you 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