Welcome to mirror list, hosted at ThFree Co, Russian Federation.

README.md « cbehave « tests - github.com/cxong/tinydir.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 62a8453703b3e1d650676114ab7c9d62018340f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
cbehave - A Behavior Driven Development Framework for C
=======
[![Build Status](https://travis-ci.org/cxong/cbehave.svg?branch=master)](https://travis-ci.org/cxong/cbehave)

A demonstration using real C code:

    #include "cbehave.h"

    // Step 1: define your functions
    int add(int a, int b);

    // Step 2: describe behaviour and the function calls
    FEATURE(addition, "Addition")
        SCENARIO("Add two numbers")
            GIVEN("we have two numbers 50 and 70")
                int a = 50;
                int b = 70;
            WHEN("we add them together")
                int r = add(a, b);
            THEN("the result should be 120")
                SHOULD_INT_EQUAL(r, 120);
        SCENARIO_END
    FEATURE_END

    // Step 3: write empty implementations of functions
    int add(int a, int b)
    {
        // Step 5: write code to make the behaviour pass
        return a + b;
    }

    // Step 4: run tests and watch them fail (and succeed later)
    CBEHAVE_RUN("Calculator Features are as below:", TEST_FEATURE(addition))

Introduction
-------------
CBehave - A Behavior Driven Development Framework for C.

Main Features
-------------

 - use the "feature + scenario" structure (inspired by Cucumber)
 - use classical "given-when-then" template to describe behavior scenarios
 - support mock

Example Output
-------------

   *******************************************************************
       CBEHAVE -- A Behavior Driven Development Framework for C
                By Tony Bai
   *******************************************************************
    Strstr Features are as belows:
    Feature: strstr
     Scenario: The strstr finds the first occurrence of the substring in the source string
         Given A source string: Lionel Messi is a great football player
         When we use strstr to find the first occurrence of [football]
         Then We should get the string: [football player]
     Scenario: If strstr could not find the first occurrence of the substring, it will return NULL
         Given A source string: FC Barcelona is a great football club.
         When we use strstr to find the first occurrence of [AC Milan]
         Then We should get no string but a NULL
     Summary:
     features: [1/1]
     scenarios: [2/2]

Build
------

To run the examples:

 - Clone the project
 - cmake cbehave/examples

To use cbehave in your CMake project:

- include the cbehave directory
- link against `cbehave`