Skip to content

Commit 233aa18

Browse files
committed
Replace FakeDriver with GenericDriver, warn when using it
1 parent 3551bd4 commit 233aa18

File tree

11 files changed

+47
-34
lines changed

11 files changed

+47
-34
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ Gemfile.lock
1111
# Build artifacts
1212
build/
1313

14-
#vim swap files
14+
# vim swap files
1515
*.swp

features/step_definitions/RpnCalculatorSteps.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#define CUKE_ENABLE_GENERICDRIVER
12
#include <cucumber-cpp/defs.hpp>
23
#include <boost/algorithm/string.hpp>
34
#include <boost/math/constants/constants.hpp>

features/step_definitions/cucumber_cpp_mappings.rb

+1
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ def append_step_definition(step_name, code) # todo params parameter?
231231
def append_support_code(code)
232232
helper_functions = get_absolute_path('../support/HelperFunctions.hpp');
233233
@support_code ||= <<-EOF
234+
#define CUKE_ENABLE_GENERICDRIVER
234235
#include <cucumber-cpp/defs.hpp>
235236
#include "#{helper_functions}"
236237
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
#if defined(GTEST_INCLUDE_GTEST_GTEST_H_)
2-
#include "GTestDriver.hpp"
2+
#include "GTestDriver.hpp"
33
#elif defined(BOOST_TEST_CASE)
4-
#include "BoostDriver.hpp"
4+
#include "BoostDriver.hpp"
55
#elif defined(CPPSPEC_H_)
6-
#include "CppSpecDriver.hpp"
6+
#include "CppSpecDriver.hpp"
77
#else // No test framework
8-
#include "FakeDriver.hpp"
8+
#ifdef CUKE_ENABLE_GENERICDRIVER
9+
#include "GenericDriver.hpp"
10+
#else
11+
#error Please #inlude testing framework before cucumber-cpp or #define CUKE_ENABLE_GENERICDRIVER explicitly
12+
#endif
913
#endif

include/cucumber-cpp/internal/drivers/FakeDriver.hpp

-26
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#ifndef CUKE_GENERICDRIVER_HPP_
2+
#define CUKE_GENERICDRIVER_HPP_
3+
4+
#include "../step/StepManager.hpp"
5+
6+
namespace cucumber {
7+
namespace internal {
8+
9+
class FakeStep : public BasicStep {
10+
protected:
11+
virtual const InvokeResult invokeStepBody();
12+
};
13+
14+
#define STEP_INHERITANCE(step_name) virtual ::cucumber::internal::FakeStep
15+
16+
}
17+
}
18+
19+
#endif /* CUKE_GENERICDRIVER_HPP_ */

src/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
set(CUKE_SOURCES
2+
drivers/GenericDriver.cpp
23
ContextManager.cpp
34
CukeCommands.cpp
45
CukeEngine.cpp

src/drivers/GenericDriver.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include "cucumber-cpp/internal/drivers/GenericDriver.hpp"
2+
3+
namespace cucumber {
4+
namespace internal {
5+
6+
const InvokeResult FakeStep::invokeStepBody() {
7+
// No try/catch block to throw the original exceptions to the testing framework
8+
body();
9+
return InvokeResult::success();
10+
}
11+
12+
}
13+
}

tests/integration/StepRegistrationTest.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include <cucumber-cpp/internal/step/StepManager.hpp>
44
#include <cucumber-cpp/internal/step/StepMacros.hpp>
5-
#include <cucumber-cpp/internal/drivers/FakeDriver.hpp>
5+
#include <cucumber-cpp/internal/drivers/GenericDriver.hpp>
66

77
using namespace cucumber::internal;
88

tests/unit/BasicStepTest.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <gtest/gtest.h>
22

3-
#include <cucumber-cpp/internal/drivers/FakeDriver.hpp>
3+
#include <cucumber-cpp/internal/drivers/GenericDriver.hpp>
44

55
using namespace cucumber::internal;
66

tests/utils/CukeCommandsFixture.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define CUKE_CUKECOMMANDSFIXTURE_HPP_
33

44
#include <cucumber-cpp/internal/CukeCommands.hpp>
5-
#include <cucumber-cpp/internal/drivers/FakeDriver.hpp>
5+
#include <cucumber-cpp/internal/drivers/GenericDriver.hpp>
66
#include "StepManagerTestDouble.hpp"
77

88
#include <boost/shared_ptr.hpp>

0 commit comments

Comments
 (0)