diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b8aaecf..a6aef791 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,7 +217,13 @@ else() add_executable(e2e-steps EXCLUDE_FROM_ALL ${CUKE_DYNAMIC_CPP_STEPS}) # Mark this file as generated so it isn't required at CMake generation time (it is necessary when the target gets built though) set_source_files_properties(${CUKE_DYNAMIC_CPP_STEPS} PROPERTIES GENERATED TRUE) - target_link_libraries(e2e-steps ${CUKE_LIBRARIES}) + target_link_libraries(e2e-steps PRIVATE ${CUKE_LIBRARIES}) + #Boost test lib required for boost specific scenario "Predicate Message" + if(Boost_UNIT_TEST_FRAMEWORK_FOUND) + target_link_libraries(e2e-steps PRIVATE ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + else() + set(CUKE_E2E_TAGS "--tags ~@boost") + endif() set(CUKE_COMPILE_DYNAMIC_CPP_STEPS '"${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target e2e-steps') @@ -242,6 +248,7 @@ else() COMPILE_DYNAMIC_CPP_STEPS=${CUKE_COMPILE_DYNAMIC_CPP_STEPS} CUCUMBER_RUBY=${CUCUMBER_RUBY} --format=junit "--out=${CMAKE_BINARY_DIR}/features" + ${CUKE_E2E_TAGS} ${ARGN} ${CUKE_FEATURES_DIR} DEPENDS cucumber-cpp @@ -249,9 +256,9 @@ else() ) endfunction(add_feature_target) - add_feature_target(features --format progress) - add_feature_target(features-pretty --format pretty) - add_feature_target(features-wip --format pretty --tags @wip) + add_feature_target(features --format progress) + add_feature_target(features-pretty --format pretty) + add_feature_target(features-wip --format pretty --tags @wip) else() message(WARNING "Could not find Cucumber: skipping end-to-end tests") diff --git a/features/specific/boost_specific.feature b/features/specific/boost_specific.feature new file mode 100644 index 00000000..c27f0097 --- /dev/null +++ b/features/specific/boost_specific.feature @@ -0,0 +1,34 @@ +@boost +Feature: Check macros used with boost test driver + + This is just a simple feature meant to test boost's + specyfic validation macros interop with cucumber. + + Scenario Outline: macro + Given the following feature: + """ + Feature: Feature name + Scenario: Scenario name + Given a step + """ + And a step definition file with: + """ + #include + #include + GIVEN("a step") { + ; + } + """ + When Cucumber runs the feature + Then the scenario + + Examples: + | check | passes or fails? | + | BOOST_CHECK(false) | fails | + | BOOST_CHECK_MESSAGE(false, "boost message") | fails with message "boost message" | + | BOOST_ERROR("boost message") | fails with message "boost message" | + | BOOST_FAIL("boost message") | fails with message "boost message" | + | BOOST_REQUIRE(false) | fails | + | BOOST_REQUIRE_MESSAGE(false, "boost message") | fails with message "boost message" | + | BOOST_WARN(false) | passes | + | BOOST_WARN_MESSAGE(false, "boost message") | passes | diff --git a/features/specific/simple.feature b/features/specific/simple.feature index a1d70eed..51e754f2 100644 --- a/features/specific/simple.feature +++ b/features/specific/simple.feature @@ -12,7 +12,7 @@ Feature: Simple Feature Scenario: Scenario name Given a step """ - And a step definition file with: + And a step definition file with support code including: """ #include diff --git a/features/step_definitions/cucumber_cpp_mappings.rb b/features/step_definitions/cucumber_cpp_mappings.rb index 43e39e18..a64deb1a 100644 --- a/features/step_definitions/cucumber_cpp_mappings.rb +++ b/features/step_definitions/cucumber_cpp_mappings.rb @@ -228,6 +228,10 @@ def append_step_definition(step_name, code) # todo params parameter? EOF end + def set_code(code) + @support_code = code + end + def append_support_code(code) helper_functions = get_absolute_path('../support/HelperFunctions.hpp'); @support_code ||= <<-EOF diff --git a/features/step_definitions/cucumber_cpp_steps.rb b/features/step_definitions/cucumber_cpp_steps.rb index b41eaa58..bcf9f0a5 100644 --- a/features/step_definitions/cucumber_cpp_steps.rb +++ b/features/step_definitions/cucumber_cpp_steps.rb @@ -1,4 +1,8 @@ Given /^a step definition file with:$/ do |code| + set_code code +end + +Given /^a step definition file with support code including:$/ do |code| append_support_code code end @@ -9,3 +13,9 @@ Then /^a step definition snippet with (".*") is suggested$/ do |regex_string| assert_partial_output("(#{regex_string}) {", all_output) end + +Then /^the scenario fails with message "([^"]*)"$/ do |message| + assert_partial_output(message, all_output) + assert_success false +end + diff --git a/src/drivers/BoostDriver.cpp b/src/drivers/BoostDriver.cpp index fcd0bf61..f96ed1b3 100644 --- a/src/drivers/BoostDriver.cpp +++ b/src/drivers/BoostDriver.cpp @@ -60,8 +60,8 @@ class CukeBoostLogInterceptor : public ::boost::unit_test::unit_test_log_formatt void log_exception_finish( std::ostream& ) {}; void log_entry_start( std::ostream&, log_entry_data const&, log_entry_types /*let*/) {}; - void log_entry_value( std::ostream&, const_string /*value*/); - void log_entry_value( std::ostream&, lazy_ostream const& /*value*/) {}; + void log_entry_value( std::ostream&, const_string value); + void log_entry_value( std::ostream&, lazy_ostream const& value); void log_entry_finish( std::ostream&) {}; void entry_context_start( std::ostream&, log_level /*l*/) {} @@ -79,7 +79,11 @@ void CukeBoostLogInterceptor::reset() { /* * Threshold level set to log_all_errors, so we should be fine logging everything */ -void CukeBoostLogInterceptor::log_entry_value( std::ostream&, const_string value) { +void CukeBoostLogInterceptor::log_entry_value(std::ostream&, const_string value) { + description << value; +} + +void CukeBoostLogInterceptor::log_entry_value(std::ostream&, lazy_ostream const& value) { description << value; }