Reputation: 3985
So I have NetBeans 8.1 running on ubuntu 14.04. I have an existing project using CMakeLists files as well as googletest. I am trying to set it up and runnig. So I installed the NBCndUnit, and then followed instructions found here: https://github.com/offa/NBCndUnit/wiki/Using-existing-projects#a-workaround-for-cmake. here's part of my project/CMakeLists file:
cmake_policy(SET CMP0037 OLD)
add_custom_target(build-tests COMMENT "starting build-tests target" )
add_custom_target(test myAppTest COMMENT "starting test target")
and here's the part of my myApp/test CMakeLists file:
add_executable(myAppTest ${SOURCES} ${HEADERS})
target_link_libraries(myAppTest
-L${GTEST_LIBRARY_DIR}
-L${GMOCK_LIBRARY_DIR}
myApp
gtest
gmock
# other dependencies
)
add_test(myAppTest myAppTest )
when I right click on the main project CMakeLists.txt file and choose "generate makefile" - it succeeds. When I then right click on the Makefile and go to Make Target submenu, I can choose several targets:
When I then choose eg. "build-tests" target - nothing happens (which is expected, as this target is empty):
cd '(some project path)/cmake_build'
/usr/bin/make -f Makefile build-tests
Built target build-tests
If i choose "test" target - it gets built and executed (output in the console window)
cd '(path to project)/cmake_build'
/usr/bin/make -f Makefile test
[ 34%] Built target dependency1
[ 54%] Built target dependency2
[ 82%] Built target dependency3
[ 88%] Built target dependency4
[ 97%] Built target dependency5
[100%] starting test target
[==========] Running 111 tests from 7 test cases.
[----------] Global test environment set-up.
[----------] 1 test from Foo
[ RUN ] Foo.Bar
[ OK ] Foo.Bar (0 ms)
[----------] 1 test from Foo (0 ms total)
(rest of gtest output)
But I would like to see the test results in Netbeans TestResults window pane. So I go to the 'Run'->'Test project' command in the menu. And here a problem appears: A new tab is added to the Output pane, it is titled myApp(Build, Build Tests...). And it tries to build the whole project:
cd '(project path)/cmake_build'
/usr/bin/make -j4 -f Makefile
the problem is, that the whole project is not yet buildable, due to dependencies. All that is necessary is mocked in the myAppTest (and the test themselves are runable - eg. by building the "test" target from makefile context menu). So the real question is: Can I somehow skip building whole project before bulding and running the actual tests?
Upvotes: 1
Views: 732
Reputation: 3985
well, i was partially able to sovle my problem. what i did, is to add custom project properties configuration scheme:
I simply added some fake build target (build_tests
), so NB builds it instead of the default all
target. Kind of hacky, but does what I need.
Upvotes: 1
Reputation: 25370
Can I somehow skip building whole project before bulding and running the actual tests?
Netbeans builds all
targets by default. This is somehow integrated I guess. One think you can try is to exclude the objects / targets from this default target.
Another way to go: Add an option which (eg. BUILD_TESTS_ONLY
) which builds only the parts needed to run the tests. This option can be off by default so it doesn't break any other builds.
Upvotes: 1