Skip to content

Migrate all tests to gtest #197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 28, 2013
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
HTTP Client Test Consolidation, Remove Boost.Test
This is the simplification of the HTTP client test suite which serves as
a guide for getting other tests migrated to use gtest. Moving forward
the idea is to accomplish the same for all of the tests in cpp-netlib:

* Consolidate logically grouped tests into a single binary.
* Remove all traces of dependency to the Boost.Test framework.
* Get all tests to a "green" state again.

This paves the way for implementing mocks for some internal classes that
we want to be able to change. In the meantime simplifying the test suite
buys us more in the long run as we add more and more tests to the
library.
  • Loading branch information
deanberris committed Jan 21, 2013
commit 113e9fb7e69beac8b3029adb2468befa07ffdb1c
6 changes: 1 addition & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ else()
set(Boost_USE_STATIC_LIBS ON)
endif()
set(Boost_USE_MULTITHREADED ON)
if(CPP-NETLIB_BUILD_TESTS)
set(Boost_COMPONENTS unit_test_framework system regex date_time filesystem program_options )
else()
set(Boost_COMPONENTS system regex date_time filesystem program_options )
endif()
set(Boost_COMPONENTS system regex date_time filesystem program_options )
find_package( Boost 1.51 REQUIRED ${Boost_COMPONENTS} )
find_package( OpenSSL )
find_package( Threads )
Expand Down
1 change: 1 addition & 0 deletions http/src/network/protocol/http/request/request_base.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define NETWORK_RPTOCOL_HTTP_REQUEST_BASE_IPP_20111102

#include <network/protocol/http/request/request_base.hpp>
#include <vector>
#include <thread>
#include <cstring>

Expand Down
123 changes: 59 additions & 64 deletions http/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ include_directories(
${CPP-NETLIB_SOURCE_DIR}/message/src
${CPP-NETLIB_SOURCE_DIR}/logging/src
${CPP-NETLIB_SOURCE_DIR}/http/src
${GTEST_INCLUDE_DIRS}
${CPP-NETLIB_SOURCE_DIR})

if (OPENSSL_FOUND)
include_directories( ${OPENSSL_INCLUDE_DIR} )
add_definitions(-DBOOST_NETWORK_ENABLE_HTTPS)
add_definitions(-DNETWORK_ENABLE_HTTPS)
endif()

if( NOT CPP-NETLIB_DISABLE_LOGGING )
Expand Down Expand Up @@ -47,6 +48,7 @@ if (Boost_FOUND)
)
target_link_libraries(cpp-netlib-http-${test}
${Boost_LIBRARIES}
${GTEST_BOTH_LIBRARIES}
${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
cppnetlib-message
Expand All @@ -62,69 +64,62 @@ if (Boost_FOUND)
${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-${test})
endforeach(test)

set ( TESTS
client_constructor_test
client_get_test
client_get_different_port_test
client_get_timeout_test
client_get_streaming_test
)
foreach ( test ${TESTS} )
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
set_source_files_properties(${test}.cpp
PROPERTIES COMPILE_FLAGS "-Wall")
endif()
add_executable(cpp-netlib-http-${test} ${test}.cpp)
target_link_libraries(cpp-netlib-http-${test}
${Boost_LIBRARIES}
${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
cppnetlib-constants
cppnetlib-uri
cppnetlib-message
cppnetlib-message-wrappers
cppnetlib-message-directives
${CPP-NETLIB_LOGGING_LIB}
cppnetlib-http-message
cppnetlib-http-message-wrappers
cppnetlib-http-client
cppnetlib-http-client-connections)
if (OPENSSL_FOUND)
target_link_libraries(cpp-netlib-http-${test} ${OPENSSL_LIBRARIES})
endif()
set_target_properties(cpp-netlib-http-${test}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests)
add_test(cpp-netlib-http-${test}
${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-${test})
endforeach (test)
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
set_source_files_properties(client_test.cpp
PROPERTIES COMPILE_FLAGS "-Wall")
endif()
add_executable(cpp-netlib-http-client_test client_test.cpp)
target_link_libraries(cpp-netlib-http-client_test
${Boost_LIBRARIES}
${GTEST_BOTH_LIBRARIES}
${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
cppnetlib-constants
cppnetlib-uri
cppnetlib-message
cppnetlib-message-wrappers
cppnetlib-message-directives
${CPP-NETLIB_LOGGING_LIB}
cppnetlib-http-message
cppnetlib-http-message-wrappers
cppnetlib-http-client
cppnetlib-http-client-connections)
if (OPENSSL_FOUND)
target_link_libraries(cpp-netlib-http-client_test ${OPENSSL_LIBRARIES})
endif()
set_target_properties(cpp-netlib-http-client_test
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests)
add_test(cpp-netlib-http-client_test
${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-${test})

#set ( SERVER_API_TESTS
# server_constructor_test
# server_async_run_stop_concurrency
# )
#foreach ( test ${SERVER_API_TESTS} )
# if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
# set_source_files_properties(${test}.cpp
# PROPERTIES COMPILE_FLAGS "-Wall")
# endif()
# add_executable(cpp-netlib-http-${test} ${test}.cpp)
# target_link_libraries(cpp-netlib-http-${test}
# ${Boost_LIBRARIES}
# ${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES}
# ${CMAKE_THREAD_LIBS_INIT}
# cppnetlib-constants
# cppnetlib-uri
# cppnetlib-message
# cppnetlib-message-wrappers
# cppnetlib-http-message
# cppnetlib-http-server
# cppnetlib-http-server-parsers
# cppnetlib-utils-thread_pool
# )
# set_target_properties(cpp-netlib-http-${test}
# PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests)
# add_test(cpp-netlib-http-${test}
# ${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-${test})
#endforeach (test)
# set ( SERVER_API_TESTS
# server_constructor_test
# server_async_run_stop_concurrency
# )
# foreach ( test ${SERVER_API_TESTS} )
# if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
# set_source_files_properties(${test}.cpp
# PROPERTIES COMPILE_FLAGS "-Wall")
# endif()
# add_executable(cpp-netlib-http-${test} ${test}.cpp)
# target_link_libraries(cpp-netlib-http-${test}
# ${Boost_LIBRARIES}
# ${GTEST_BOTH_LIBRARIES}
# ${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES}
# ${CMAKE_THREAD_LIBS_INIT}
# cppnetlib-constants
# cppnetlib-uri
# cppnetlib-message
# cppnetlib-message-wrappers
# cppnetlib-http-message
# cppnetlib-http-server
# cppnetlib-http-server-parsers
# cppnetlib-utils-thread_pool
# )
# set_target_properties(cpp-netlib-http-${test}
# PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests)
# add_test(cpp-netlib-http-${test}
# ${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-${test})
# endforeach (test)

endif()
32 changes: 0 additions & 32 deletions http/test/client_constructor_test.cpp

This file was deleted.

26 changes: 0 additions & 26 deletions http/test/client_get_different_port_test.cpp

This file was deleted.

56 changes: 0 additions & 56 deletions http/test/client_get_streaming_test.cpp

This file was deleted.

57 changes: 0 additions & 57 deletions http/test/client_get_test.cpp

This file was deleted.

26 changes: 0 additions & 26 deletions http/test/client_get_timeout_test.cpp

This file was deleted.

23 changes: 0 additions & 23 deletions http/test/client_include_inlined.cpp

This file was deleted.

Loading