Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ Gemfile.lock
# Build artifacts
build/

#vim swap files
# vim swap files
*.swp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <boost/test/unit_test.hpp>
#include <cucumber-cpp/defs.hpp>
#include <cucumber-cpp/autodetect.hpp>

#include <Calculator.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <CppSpec/CppSpec.h>
#include <cucumber-cpp/defs.hpp>
#include <cucumber-cpp/autodetect.hpp>

#include <Calculator.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <gtest/gtest.h>
#include <cucumber-cpp/defs.hpp>
#include <cucumber-cpp/autodetect.hpp>

#include <Calculator.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <cstdlib>
#include <boost/test/unit_test.hpp>
#include <cucumber-cpp/defs.hpp>
#include <cucumber-cpp/autodetect.hpp>
#include <QApplication>
#include <QTest>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <cstdlib>
#include <gtest/gtest.h>
#include <cucumber-cpp/defs.hpp>
#include <cucumber-cpp/autodetect.hpp>
#include <QApplication>
#include <QTest>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <gtest/gtest.h>
#include <cucumber-cpp/defs.hpp>
#include <cucumber-cpp/autodetect.hpp>

#include <string>
#include <map>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <gtest/gtest.h>
#include <cucumber-cpp/defs.hpp>
#include <cucumber-cpp/autodetect.hpp>

#include <iostream>

Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/RpnCalculatorSteps.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <cucumber-cpp/defs.hpp>
#include <cucumber-cpp/autodetect.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/math/constants/constants.hpp>
#include <boost/format.hpp>
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/cucumber_cpp_mappings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def append_step_definition(step_name, code) # todo params parameter?
def append_support_code(code)
helper_functions = get_absolute_path('../support/HelperFunctions.hpp');
@support_code ||= <<-EOF
#include <cucumber-cpp/defs.hpp>
#include <cucumber-cpp/generic.hpp>
#include "#{helper_functions}"

using cucumber::ScenarioScope;
Expand Down
4 changes: 4 additions & 0 deletions include/cucumber-cpp/autodetect.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "internal/defs.hpp"
#ifndef STEP_INHERITANCE
#error No test framework found: please include a testing framework before autodetect.hpp or include generic.hpp
#endif
11 changes: 5 additions & 6 deletions include/cucumber-cpp/defs.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "internal/step/StepManager.hpp"
#include "internal/hook/HookRegistrar.hpp"
#include "internal/ContextManager.hpp"

#include "internal/Macros.hpp"
#include "internal/drivers/DriverSelector.hpp"
#warning Use of defs.hpp is deprecated, please use either autodetect.hpp or generic.hpp
#include "internal/defs.hpp"
#ifndef STEP_INHERITANCE
#include "internal/drivers/GenericDriver.hpp"
#endif
12 changes: 0 additions & 12 deletions include/cucumber-cpp/deprecated-defs.hpp

This file was deleted.

6 changes: 6 additions & 0 deletions include/cucumber-cpp/generic.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "internal/defs.hpp"
#ifdef STEP_INHERITANCE
#error Test framework found: please include autodetect.hpp or remove the test framework includes
#else
#include "internal/drivers/GenericDriver.hpp"
#endif
5 changes: 5 additions & 0 deletions include/cucumber-cpp/internal/defs.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "step/StepManager.hpp"
#include "hook/HookRegistrar.hpp"
#include "ContextManager.hpp"
#include "Macros.hpp"
#include "drivers/DriverSelector.hpp"
8 changes: 3 additions & 5 deletions include/cucumber-cpp/internal/drivers/DriverSelector.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#if defined(GTEST_INCLUDE_GTEST_GTEST_H_)
#include "GTestDriver.hpp"
#include "GTestDriver.hpp"
#elif defined(BOOST_TEST_CASE)
#include "BoostDriver.hpp"
#include "BoostDriver.hpp"
#elif defined(CPPSPEC_H_)
#include "CppSpecDriver.hpp"
#else // No test framework
#include "FakeDriver.hpp"
#include "CppSpecDriver.hpp"
#endif
26 changes: 0 additions & 26 deletions include/cucumber-cpp/internal/drivers/FakeDriver.hpp

This file was deleted.

19 changes: 19 additions & 0 deletions include/cucumber-cpp/internal/drivers/GenericDriver.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef CUKE_GENERICDRIVER_HPP_
#define CUKE_GENERICDRIVER_HPP_

#include "../step/StepManager.hpp"

namespace cucumber {
namespace internal {

class GenericStep : public BasicStep {
protected:
virtual const InvokeResult invokeStepBody();
};

#define STEP_INHERITANCE(step_name) virtual ::cucumber::internal::GenericStep

}
}

#endif /* CUKE_GENERICDRIVER_HPP_ */
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
set(CUKE_SOURCES
drivers/GenericDriver.cpp
ContextManager.cpp
CukeCommands.cpp
CukeEngine.cpp
Expand Down
13 changes: 13 additions & 0 deletions src/drivers/GenericDriver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "cucumber-cpp/internal/drivers/GenericDriver.hpp"

namespace cucumber {
namespace internal {

const InvokeResult GenericStep::invokeStepBody() {
// No try/catch block to throw the original exceptions to the testing framework
body();
return InvokeResult::success();
}

}
}
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ if(Boost_UNIT_TEST_FRAMEWORK_FOUND)
cuke_add_driver_test(integration/drivers/BoostDriverTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
endif()

cuke_add_driver_test(integration/drivers/GenericDriverTest)
4 changes: 2 additions & 2 deletions tests/integration/StepRegistrationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

#include <cucumber-cpp/internal/step/StepManager.hpp>
#include <cucumber-cpp/internal/step/StepMacros.hpp>
#include <cucumber-cpp/internal/drivers/FakeDriver.hpp>
#include <cucumber-cpp/internal/drivers/GenericDriver.hpp>

using namespace cucumber::internal;

#define MANUAL_STEP_MATCHER "manual step"

class ManualStep : public FakeStep {
class ManualStep : public GenericStep {
public:
void body() {};
//private:
Expand Down
4 changes: 1 addition & 3 deletions tests/integration/drivers/BoostDriverTest.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include <boost/version.hpp>

#include <boost/test/unit_test.hpp>

#include <cucumber-cpp/defs.hpp>
#include <cucumber-cpp/autodetect.hpp>

#include "../../utils/DriverTestRunner.hpp"

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/drivers/CppSpecDriverTest.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <CppSpec/CppSpec.h>
#include <cucumber-cpp/defs.hpp>
#include <cucumber-cpp/autodetect.hpp>

#include "../../utils/DriverTestRunner.hpp"

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/drivers/GTestDriverTest.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <gtest/gtest.h>
#include <cucumber-cpp/defs.hpp>
#include <cucumber-cpp/autodetect.hpp>

#include "../../utils/DriverTestRunner.hpp"

Expand Down
29 changes: 29 additions & 0 deletions tests/integration/drivers/GenericDriverTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <cucumber-cpp/generic.hpp>

#include "../../utils/DriverTestRunner.hpp"

using namespace cucumber;

THEN(SUCCEED_MATCHER) {
ScenarioScope<SomeContext> ctx;
// Do not throw for successes
}

THEN(FAIL_MATCHER) {
ScenarioScope<SomeContext> ctx;
throw std::runtime_error("Failure description");
}

THEN(PENDING_MATCHER_1) {
pending();
}

THEN(PENDING_MATCHER_2) {
pending(PENDING_DESCRIPTION);
}

using namespace cucumber::internal;

int main(int argc, char **argv) {
return DriverTest().run();
}
6 changes: 3 additions & 3 deletions tests/unit/BasicStepTest.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#include <gtest/gtest.h>

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

using namespace cucumber::internal;

#define PENDING_STEP_DESCRIPTION "A description"

class PendingStep : public FakeStep {
class PendingStep : public GenericStep {
void body() {
pending();
}
};

class PendingStepWithDescription : public FakeStep {
class PendingStepWithDescription : public GenericStep {
void body() {
pending(PENDING_STEP_DESCRIPTION);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/CukeCommandsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CukeCommandsTest : public CukeCommandsFixture {
}
};

class CheckAllParameters : public FakeStep {
class CheckAllParameters : public GenericStep {
protected:
static const int arg_0_int;
static const double arg_1_double;
Expand Down
4 changes: 2 additions & 2 deletions tests/utils/CukeCommandsFixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
#define CUKE_CUKECOMMANDSFIXTURE_HPP_

#include <cucumber-cpp/internal/CukeCommands.hpp>
#include <cucumber-cpp/internal/drivers/FakeDriver.hpp>
#include <cucumber-cpp/internal/drivers/GenericDriver.hpp>
#include "StepManagerTestDouble.hpp"

#include <boost/shared_ptr.hpp>

using namespace cucumber::internal;
using boost::shared_ptr;

class EmptyStep : public FakeStep {
class EmptyStep : public GenericStep {
void body() {}
};

Expand Down