Improve unit testing directory structure
Separate Qt tests and gtest tests Add a basic shadow of the project structure Add a few simple tests to demonstrate usage
This commit is contained in:
@@ -1,10 +1,3 @@
|
||||
# 'Google_test' is the subproject name
|
||||
project(Google_tests)
|
||||
|
||||
if(WIN32)
|
||||
add_definitions(-DCOIN_DLL)
|
||||
endif(WIN32)
|
||||
|
||||
if(MSVC)
|
||||
option(
|
||||
gtest_force_shared_crt
|
||||
@@ -32,56 +25,7 @@ if(MSVC)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# 'lib' is the folder with Google Test sources
|
||||
add_executable(Tests_run)
|
||||
add_subdirectory(lib)
|
||||
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
|
||||
|
||||
# 'Google_Tests_run' is the target name
|
||||
|
||||
# 'test1.cpp tests2.cpp' are source files with tests
|
||||
add_executable(
|
||||
Google_Tests_run
|
||||
src/test1.cpp
|
||||
src/test2.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(Google_Tests_run gtest gtest_main ${Google_Tests_LIBS})
|
||||
|
||||
# ------------------------------------------------------
|
||||
|
||||
enable_testing()
|
||||
|
||||
function(SETUP_TESTS)
|
||||
foreach(_testname ${ARGN})
|
||||
add_executable(${_testname}_Tests_run src/${_testname}.cpp)
|
||||
add_test(NAME ${_testname}_Tests_run COMMAND ${_testname}_Tests_run)
|
||||
if(NOT BUILD_DYNAMIC_LINK_PYTHON)
|
||||
list(APPEND ${_testname}_LIBS
|
||||
${PYTHON_LIBRARIES}
|
||||
)
|
||||
endif()
|
||||
target_link_libraries(${_testname}_Tests_run ${QtTest_LIBRARIES} ${${_testname}_LIBS})
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
# Qt Test
|
||||
include_directories(
|
||||
${QtGui_INCLUDE_DIRS}
|
||||
${QtTest_INCLUDE_DIRS}
|
||||
${COIN3D_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
# ------------------------------------------------------
|
||||
|
||||
set (InventorBuilder_LIBS
|
||||
${COIN3D_LIBRARIES}
|
||||
FreeCADBase
|
||||
)
|
||||
|
||||
SETUP_TESTS(
|
||||
InventorBuilder
|
||||
)
|
||||
|
||||
add_subdirectory(src)
|
||||
target_link_libraries(Tests_run gtest_main ${Google_Tests_LIBS} FreeCADApp)
|
||||
|
||||
7
tests/src/App/Branding.cpp
Normal file
7
tests/src/App/Branding.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "App/Branding.h"
|
||||
|
||||
TEST(Branding, one){
|
||||
QString ss {};
|
||||
}
|
||||
5
tests/src/App/CMakeLists.txt
Normal file
5
tests/src/App/CMakeLists.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
target_sources(
|
||||
Tests_run
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Branding.cpp
|
||||
)
|
||||
8
tests/src/Base/Builder3D.cpp
Normal file
8
tests/src/Base/Builder3D.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <QString>
|
||||
#include "Base/Builder3D.h"
|
||||
|
||||
TEST(Builder, one){
|
||||
QString ss{};
|
||||
}
|
||||
@@ -1,20 +1,5 @@
|
||||
|
||||
add_executable(
|
||||
Tests_Tools_run
|
||||
tst_Tools.cpp
|
||||
target_sources(
|
||||
Tests_run
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tst_Tools.cpp
|
||||
)
|
||||
|
||||
set (Tests_Tools_LIBS
|
||||
gtest
|
||||
gtest_main
|
||||
${Google_Tests_LIBS}
|
||||
FreeCADBase
|
||||
)
|
||||
|
||||
if(NOT BUILD_DYNAMIC_LINK_PYTHON)
|
||||
list(APPEND Tests_Tools_LIBS
|
||||
${PYTHON_LIBRARIES}
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(Tests_Tools_run ${Tests_Tools_LIBS})
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
add_subdirectory(Base)
|
||||
add_subdirectory(App)
|
||||
add_subdirectory(Gui)
|
||||
add_subdirectory(Misc)
|
||||
add_subdirectory(Qt)
|
||||
|
||||
7
tests/src/Gui/Assistant.cpp
Normal file
7
tests/src/Gui/Assistant.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "Gui/Assistant.h"
|
||||
|
||||
TEST(Assistant, first){
|
||||
|
||||
}
|
||||
5
tests/src/Gui/CMakeLists.txt
Normal file
5
tests/src/Gui/CMakeLists.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
target_sources(
|
||||
Tests_run
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Assistant.cpp
|
||||
)
|
||||
6
tests/src/Misc/CMakeLists.txt
Normal file
6
tests/src/Misc/CMakeLists.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
target_sources(
|
||||
Tests_run
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test1.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test2.cpp
|
||||
)
|
||||
48
tests/src/Qt/CMakeLists.txt
Normal file
48
tests/src/Qt/CMakeLists.txt
Normal file
@@ -0,0 +1,48 @@
|
||||
# 'Google_test' is the subproject name
|
||||
project(Google_tests)
|
||||
|
||||
if(WIN32)
|
||||
add_definitions(-DCOIN_DLL)
|
||||
endif(WIN32)
|
||||
|
||||
# 'lib' is the folder with Google Test sources
|
||||
|
||||
# 'Google_Tests_run' is the target name
|
||||
#target_link_libraries(Google_Tests_run gtest gtest_main ${Google_Tests_LIBS})
|
||||
|
||||
# ------------------------------------------------------
|
||||
|
||||
enable_testing()
|
||||
|
||||
function(SETUP_TESTS)
|
||||
foreach(_testname ${ARGN})
|
||||
add_executable(${_testname}_Tests_run ${_testname}.cpp)
|
||||
add_test(NAME ${_testname}_Tests_run COMMAND ${_testname}_Tests_run)
|
||||
if(NOT BUILD_DYNAMIC_LINK_PYTHON)
|
||||
list(APPEND ${_testname}_LIBS
|
||||
${PYTHON_LIBRARIES}
|
||||
)
|
||||
endif()
|
||||
target_link_libraries(${_testname}_Tests_run ${QtTest_LIBRARIES} ${${_testname}_LIBS})
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
# Qt Test
|
||||
include_directories(
|
||||
${QtGui_INCLUDE_DIRS}
|
||||
${QtTest_INCLUDE_DIRS}
|
||||
${COIN3D_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
# ------------------------------------------------------
|
||||
|
||||
set (InventorBuilder_LIBS
|
||||
${COIN3D_LIBRARIES}
|
||||
FreeCADBase
|
||||
)
|
||||
|
||||
SETUP_TESTS(
|
||||
InventorBuilder
|
||||
)
|
||||
Reference in New Issue
Block a user