You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Build with Test-driven Development for Test-driven Developers.
15
15
16
-
## Where to get CppUTest
16
+
## Setting up CppUTest
17
17
18
-
### Pre-packaged
18
+
There are several ways to setup CppUTest. One is to install via package management and the other is from source. The big difference is that from source you can use `MakefileWorker.mk`. MakefileWorker is not supported pre-packaged. MakefileWorker does not require you to know a lot about `make` and makefiles to get started.
19
+
20
+
An easy way to get your first test case running is to use James Grenning's [cpputest-starter-project for gcc](https://github.com/jwgrenning/cpputest-starter-project) or [cpputest-starter-project for Visual Studio](https://github.com/jwgrenning/cpputest-starter-project-vs). James is the author of [Test-Driven Development for Embedded C](https://wingman-sw.com/tddec). You'll find instructions, your first test case, and some other example code. James' training resources use MakefileWorker, so you need to install from source.
21
+
22
+
Adding tests to untested C and C++ can be a big challenge. You might find [Get your Legacy C into a Test Harness](https://wingman-sw.com/articles/tdd-legacy-c) a useful recipe and resource. The page includes links to numerous articles of real legacy C challenges.
23
+
24
+
### Pre-packaged install
19
25
20
26
*Linux*
21
27
@@ -33,11 +39,11 @@ For Mac, a Homebrew package is available too. You can install via:
33
39
$ brew install cpputest
34
40
{% endhighlight %}
35
41
36
-
### From source
42
+
### From source install
37
43
38
44
You can download the latest 'automatically released' version:
39
45
40
-
*[Latest version passing the build](https://github.com/cpputest/cpputest.github.io/blob/master/releases/cpputest-3.7dev.tar.gz?raw=true)
46
+
*[Latest version passing the build](https://github.com/cpputest/cpputest.github.io/blob/master/releases/cpputest-3.8dev.tar.gz?raw=true)
41
47
This version is automatically packages after a build has passed.
42
48
43
49
Alternatively, you can clone the github repository, read-only:
@@ -52,7 +58,13 @@ Or clone it via ssh (which requires a github account)
52
58
$ git clone git@github.com:cpputest/cpputest.git
53
59
{% endhighlight %}
54
60
55
-
After you have cloned CppUTest, you can build it with your favorite build tool (CMake or autoconf).
61
+
CppUTest can also be added to your git repo as a git submodule.
Now that you have CppUTest sources, you can build it with your favorite build tool (CMake or autoconf).
56
68
57
69
Building with autoconf requires you to (this requires you to have installed GNU autotools, apt-get/brew install automake autoconf libtool):
58
70
@@ -63,6 +75,39 @@ $ ../configure
63
75
$ make
64
76
{% endhighlight %}
65
77
78
+
**NOTE**: Building from `cpputest_build` means you will not be able to use `MakefileWorker.mk`. To use MakefileWorker you need to build from the cpputest home directory.
79
+
80
+
### Using CppUTest with `MakefileWorker.mk` and gcc
81
+
82
+
If you want to use CppUTest's `MakefileWorker.mk`, you cannot currently get CppUTest using the "Pre-packaged" options described above. Instead you can get CppUTest from source using the options already described.
83
+
84
+
Change to the top level directory of CppUTest (the directory containing `include/` and `src/` among other files)
85
+
86
+
{% highlight bash %}
87
+
$ cd cpputest \
88
+
$ autoreconf . -i
89
+
$ ./configure
90
+
$ make tdd
91
+
$ export CPPUTEST_HOME=$(pwd).
92
+
{% endhighlight %}
93
+
94
+
You will want to add `export CPPUTEST_HOME=<path>` somewhere like `.bashrc` or in your build script as a relative path.
95
+
96
+
### Using CppUTest with `MakefileWorker.mk` and Visual Studio
97
+
98
+
You can build CppUTest using cmake or in the Visual Studio IDE.
99
+
100
+
*from Visual Studio IDE*
101
+
102
+
Depending on your VS version double click either
103
+
104
+
*`CppUTest_VS201x.sln` - for VS 2010 and later
105
+
*`CppUTest.sln` - for pre VS 2010
106
+
107
+
Say yes to suggested conversions. Select the menu item corresponding to run without debugging. CppUTest should build (probably with warnings). When the build completes the test runner runs. You should see over 1000 tests passing and no test failures. The build also produced a static library (cpputest/lib) holding CppUTest you can link your tests to.
108
+
109
+
To use CppUTest, define an environment variable `CPPUTEST_HOME` that points to the home directory of CppUTest. You will find a working example and some more help in [cpputest-starter-project for Visual Studio](https://github.com/jwgrenning/cpputest-starter-project-vs).
110
+
66
111
## How to create a coverage report
67
112
68
113
You can use autoconf to create a coverage report for CppUTests own tests. If you have lcov installed, a browsable html report will be generated as well. After the steps outlined in the previous paragraph, do the following:
Copy file name to clipboardExpand all lines: manual.markdown
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -379,6 +379,10 @@ public:
379
379
380
380
Yes, its ugly. But usually people don't overload operator new everywhere. If you do, consider turning off the new macro completely.
381
381
382
+
### Other conflicts in the test file only
383
+
384
+
If your conflict is only in the test code files, put the CppUTest includes after your includes. Because of this potential conflict, its a good idea to put the CppUTest includes after your includes as a preemptive measure.
0 commit comments