CucumberCPPDemoProject
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:
#What is this?
This is a setup and build exercise for Cucumber-CPP on Ubuntu 10.04. It does not (yet) attempt to explain how to use Cucumber to do ATDD. You should be able to setup Cucumber-CPP and a simple test project using this information with little or no difficulty. 

>
> This example is _not_ intended to convey best practices for writing Gherkin
>

Soon, more stuff about what is ATDD, What is Cucumber, How does it all work? When should I do this? etc. will be added to this project.

If you have any suggestions or comments, please let me know.

#Notice: Ubuntu 12.04
I've just received comments that this is *not* working on Ubuntu 12.04. I'll work out the why and update soon on that topic.

#Assuming you are starting from Ubuntu 10.04 i386 iso

```
http://mirror.anl.gov/pub/ubuntu-iso/DVDs/ubuntu/10.04/release/
http://mirror.anl.gov/pub/ubuntu-iso/DVDs/ubuntu/10.04/release/ubuntu-10.04.4-dvd-i386.iso
```

#Setup the development environment

##Install curl, a text editor, cmake, make, g++, and git

>
> I've left the editor install out. I prefer emacs, you may choose some other tool.
>
> For example you could use;
> 
> sudo apt-get install emacs
>
> *OR*
>
> sudo apt-get install vim
>
> *OR*
>
> use gedit which should already be available in your applications menu
>

```bash
sudo apt-get install curl cmake make g++ git-core
```

## Install Boost 

```bash
sudo apt-get install libboost-all-dev
```
>
> The boost libraries are necessary for the cucmber-cpp implementation. 
> While a more concise subset of the boost libraries is required, it is easiest to just
> install them all
>

## Install GTest 

```bash
sudo apt-get install libgtest-dev
```

>
> There are alaternatives here, however GTest provides a simple set of assertion macros that can
> be used in the step files. Boost also provides a set of assertion classes, as does CPPSPEC. We
> don't use CPPSPEC because no documentation is available (due to link rot). 
>

## Install ruby and the appropriate gems

```bash
sudo apt-get install zlib1g zlib1g-dev libyaml-0-2 libyaml-dev
curl -L https://get.rvm.io | bash -s stable --ruby
source ~/.bashrc
rvm install 1.9.3
```

>
> Cucumber comes to us from the Ruby world. Cucmber-CPP works with Cucumber via the *wire protocol*. 
> So in order to make this all work we need the Ruby part of Cucumber to execute our feature files. 
> Here is a short description of the way the wire protocol works; https://github.com/cucumber/cucumber/wiki/Wire-Protocol
>

## Get the gems for cucumber

```bash
gem install gherkin cucumber
source ~/.rvm/scripts/rvm
```

>
> Gems are a Ruby technology that allow you to pull in modules of code from other sources. In this case
> we are pulling in gherkin and cucumber. Here ***the orderder is important*** so be sure to pull gherkin
> first. Gherkin is the interpreter for your feature files. Cucumber uses this to read and execute the steps
> you have defined in a scenario. Cucumber is the test execution engine. It also creates the output.
>

## Download Cucumber-CPP

###Create a projects folder from your home directory

```bash
mkdir projects
```

###Change the current directory to your new projects directory

```bash
cd projects
```

###Use git to copy the cucumber project

```bash
git clone https://github.com/cucumber/cucumber-cpp.git
```

### Compile Cucumber-CPP

Change current directory

```bash
cd cucumber-cpp
```

Build cucumber with the following commands
  
```bash      
cmake -E make_directory build
cmake -E chdir build cmake -DCUKE_ENABLE_EXAMPLES=on ..
cmake --build build
cmake --build build --target test
```

>
> ***Note*** You should see some warnings, but no errors at this point. If you see a warning that Google Test (GTEST) was *not* found, the following step(s) will fail. Go back and check to see that Google Test was installed correctly. You can do this by looking for the following information;
>
> 1. You have the binary librarires for Google Test in */usr/lib*
>    1.1. 
>    1.1. /usr/lib/libgtest.a
>    1.1. /usr/lib/libgtest.la
>    1.1. /usr/lib/libgtest_main.a
>    1.1. /usr/lib/libgtest_main.la
>    1.1. /usr/lib/libgtest_main.so
>    1.1. /usr/lib/libgtest_main.so.0
>    1.1. /usr/lib/libgtest_main.so.0.0.0
>    1.1. /usr/lib/libgtest.so
>    1.1. /usr/lib/libgtest.so.0
>    1.1. /usr/lib/libgtest.so.0.0.0 
> 1. You have the include headers for Google Test in */usr/include/gtest*
>
> If these conditions are not true, go back and check what happened when you ran *sudo apt-get install libgtest-dev*
>
> ***Note:*** we know this isn't working correctly on Ubuntu 12.04 at this time.

##Test cucumber 

###Run an example

```bash
build/examples/Calc/GTestCalculatorSteps >/dev/null &
cucumber -s examples/Calc/CalcFeatures
```

>
> **Note:** The -s flag disables source line reporting in the output. You can try this command without the -s and see that each line of the feature file is reported next to its output. I find that annoying, so I surpress that part of the output.
>

Your output should look like this;

```cucumber         
# language: en
 Feature: Addition
     In order to avoid silly mistakes
     As a math idiot 
     I want to be told the sum of two numbers
        
     Scenario Outline: Add two numbers                    
       Given I have entered  into the calculator 
       And I have entered  into the calculator   
       When I press 

本源码包内暂不包含可直接显示的源代码文件,请下载源码包。