Feature unittest (#157)
* Adding support for unit testing using boost unit test and ctest * Adding libboost-test to Travis config. * Adding libboost-test to Travis config. * Modifying per element comparison * Modifying per element comparison * Fixing typo * Fixing typo * Adding custom comparison for strings * Updating Travis to run unit tests * Updating Travis to run unit tests * Fixing typo * Preparing unit testing to run on Appveyor * Preparing unit testing to run on Appveyor * Preparing unit testing to run on Appveyor * Preparing unit testing to run on Appveyor and Travis * Preparing unit testing to run on Appveyor and Travis * Preparing unit testing to run on Appveyor and Travis * Preparing unit testing to run on Appveyor * Preparing unit testing to run on Appveyor * Fixing unit testing path issue in CMake * Fixing unit testing path issue in CMake * Fixing bugs in cmake and appveyor scripts * Rolling back generate_export_header in cmake
This commit is contained in:
committed by
Sam Hatchett
parent
63b4438765
commit
bbe40c5ba4
46
tests/CMakeLists.txt
Normal file
46
tests/CMakeLists.txt
Normal file
@@ -0,0 +1,46 @@
|
||||
#
|
||||
# CMakeLists.txt - CMake configuration file for epanet/tests
|
||||
#
|
||||
# Created: February 13, 2018
|
||||
# Author: Constantin Savtchenko
|
||||
# Ref: http://neyasystems.com/an-engineers-guide-to-unit-testing-cmake-and-boost-unit-tests/
|
||||
#
|
||||
# Modified by: Michael E. Tryby
|
||||
# US EPA ORD/NRMRL
|
||||
#
|
||||
|
||||
#Setup CMake to run tests
|
||||
enable_testing()
|
||||
|
||||
|
||||
# Sets for output directory for executables and libraries.
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
|
||||
#Prep ourselves for compiling boost
|
||||
find_package(Boost REQUIRED)
|
||||
include_directories (${Boost_INCLUDE_DIRS})
|
||||
|
||||
|
||||
#I like to keep test files in a separate source directory called test
|
||||
file(GLOB TEST_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} test_*.cpp)
|
||||
|
||||
|
||||
#Run through each source
|
||||
foreach(testSrc ${TEST_SRCS})
|
||||
#Extract the filename without an extension (NAME_WE)
|
||||
get_filename_component(testName ${testSrc} NAME_WE)
|
||||
|
||||
#Add compile target
|
||||
add_executable(${testName} ${testSrc})
|
||||
|
||||
#link to Boost libraries AND your targets and dependencies
|
||||
target_link_libraries(${testName} ${Boost_LIBRARIES} epanet epanet-output)
|
||||
|
||||
|
||||
#Finally add it to test execution -
|
||||
#Notice the WORKING_DIRECTORY and COMMAND
|
||||
add_test(NAME ${testName}
|
||||
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${testName}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data)
|
||||
endforeach(testSrc)
|
||||
Reference in New Issue
Block a user