We’ve adopted agile testing in the form of Behavior Driven Development (BDD) as part of our agile development process, and use Cucumber features extensively on Ruby on Rails web application projects for our own customer software development projects, although we have done Java, Delphi and C# implementations of agile testing as well using BDD and Cucumber.
Cucumber for C++
A recent project called for the introduction of agile testing using BDD to an existing Windows code base, with a large portion of the code being developed in C++. Cucumber-cpp is currently the most active implementation of Cucumber for C++. It can be used on Linux, Mac OS X as well as Windows.
The current cucumber-cpp library relies on at least one of the following libraries:[list_icon color=”blue” type=”icon_arrow”]
- Boost 1.40 or later
- GTest 1.4 or later
- CppSpec development branch
- GMock 1.6 or later
We’ve decided to use Boost, specifically version 1.5.2 (the most current version at the time). The following software was used on Windows 8:[list_icon color=”blue” type=”icon_arrow”]
- CMake – version 2.8.10
- Boost – version 1.52.0
- Cucumber-cpp – master branch
- Visual Studio 2012
- Ruby 1.9.3 with the cucumber gem
Installing cucumber-cpp on Windows
Installing cucumber-cpp and the included example on Windows proved to be quite a challenge, largely as a result of the dependency on Boost and it’s test framework. Installation on Linux was trivial in comparison, and the instructions at the library’s Github page worked as expected (for use on Linux).
Step 1: Install Ruby
There are various options to install Ruby on Windows, we’ve used RubyInstaller 1.9.3-p374 as found on the Ruby Installer web site.
Verify the installation in a Windows console:
Once Ruby is installed, install the cucumber gem:
gem install cucumber
Step 2: Install CMake 2.8.10
We’ve decided to use the pre-compiled binary as found on the CMake web site, and it installed perfectly without any issues.
Step 3: Install Boost 1.52.0
Boost was another kettle of fish, especially since it’s unit tests must be included to ensure that cucumber-cpp can be compiled and linked properly. Download the source from the Boost web site and extract into C:\Boost\boost_1_52_0, and then use the following to build Boost (warning, this will take quite a while to complete):
.\b2 –prefix=c:\Boost –build-type=complete –with-thread
–with-regex –with-system –with-date_time –with-test
–with-filesystem –with-chrono –with-program_options
Once built, add C:\Boost\lib to the Window system PATH (to ensure that the applicable .dll files are found at runtime when running the executables that will be built in Visual Studio.
Step 4: Build the cucumber-cpp library and example
Download or clone the latest version of cucumber-cpp from the github repository into C:\Cucumber\cucumber-cpp and follow these instructions to prepare a Visual Studio project file:
cmake -E make_directory vsprj
cmake -E chdir vsprj cmake -G”Visual Studio 11″
-DCUKE_ENABLE_EXAMPLES=on -DBOOST_ROOT=c:\Boost . ..
Once done, open C:\Cucumber\cucumber-cpp\vsprj\Cucumber-Cpp.sln with Visual Studio 2012 and build the project.
Running the features
Two steps in a Windows terminal or console are required to run the given example features (change to C:\Cucumber\cucumber-cpp).
a) Run the cucumber-cpp listener
A new terminal window should load up, with ‘Listening on port 3902’ as the output.
b) Run features
If all goes well, you should see the following output (showing output inside console2 with ansicon):
Bonus feature: Improve the Windows console output
The default output are not colour coded (as one would expect), we’ve installed console2 with ansicon (x86 on Windows 8) to fix this.
More information can be found here:
References and resources[list_icon color=”blue” type=”icon_arrow”]
- The official Cucumber site: http://cukes.info/
- Cucumber Google group: http://groups.google.com/group/cukes/topics
- Cucumber @ github.com: https://github.com/cucumber
- Cucumber-cpp: https://github.com/cucumber/cucumber-cpp
- Ruby Installer: http://rubyinstaller.org/
- Boost resources: http://www.boost.org/ & http://www.boost.org/doc/libs/1_52_0/more/getting_started/windows.html
- CMake resources: http://www.cmake.org/cmake/resources/software.html & http://www.cmake.org/cmake/help/install.html
BY: SOFTWARE DEVELOPER AT INFOWARE STUDIOS
Interesting Infoware Studios Bookmarks
- See on delicious : ruby
WP HTTP Error: Could not resolve host: feeds.delicious.com