Giter Site home page Giter Site logo

evolvedhq / cookiecutter-kata-gtest Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 1.0 1.69 MB

A cookiecutter template for creating a simple C++ TDD code kata project using with Google Test / Google Mock

License: GNU General Public License v3.0

CMake 0.80% C++ 85.39% Makefile 0.65% Shell 0.67% M4 0.64% C 0.43% Python 11.41%
kata cpp google-test cmake

cookiecutter-kata-gtest's Introduction

Template for TDD Code Katas in C++

Hey there. This is a cookiecutter template for a simple TDD code kata using Google Test/Google Mock. It's intended to give you a repeatable way of very quickly getting started for a "deliberate practice" session with C++.

Features of this template

This generates a project for doing a test-driven code kata in C++.

  • Includes Google Test and Google Mock libraries
  • Generates a header, "production" source file and an empty test
  • Generates a CMake build which will work on most platforms
  • Has some convenience targets for generating etags and running unit tests

Pre-requisites

You'll need to have cookiecutter installed. This is a Python tool - on most platforms, install using:

$ pip install cookiecutter

After the kata project is created, you'll need to generate a build using CMake, and then of course compile, link and execute the kata. This is all going to take a fairly complete C++ development toolchain, and you'll need to figure out how to get this configured for your platform, if you don't already have one.

The minimum requirements for building this are really those from Google Test/Google Mock, which supports C++98 or later (although we'd suggest that TDD in C++ is so much more fun with C++14 or later using a modern toolchain...).

Generating your project

Start by invoking cookiecutter. This can be done locally - handy if you're working disconnected:

$ cookiecutter <path-to-this-template>

or directly from the GitHub URL where the template lives:

$ cookiecutter https://github.com/13coders/cookiecutter-kata-gtest

This template is intended to be very simple, so cookiecutter will prompt you for only three parameters when you are creating your project:

kata [CodeKata]: 

This is name/title of the Code Kata. Whatever name you provide will be capitalised exactly as you enter it:

  • If you use camel case, the name of the test file, source file and header will be, for example "GameOfLife.cpp", "GameOfLifeTest.cpp" etc

  • The name will be lowercased for the CMake file, the name of the repository, the value in the #include guard and the dummy namespace that's generated in the header

So, if you prefer CamelCase file names, use something like "GameOfLife" as the kata name, or if you prefer snake_case file names, then use "game_of_life".

Select etags:
1 - y
2 - n
Choose from 1, 2 [1]: 1

This lets you decide whether or not to include the build file magic for generating an etags file when recompiling-, which defaults to "y". If you choose no, there will be no dependency on etags in the build.

If you want to, you can always add any extra tools you need (static analyzers, sanitizers etc) into the CMake file yourself - it's a minimal starting point.

Select license:
1 - GNU General Public License v3
2 - MIT license
3 - Apache Software License 2.0
Choose from 1, 2, 3 [1]: 1

Lets you select the free/open source license for your kata sources. If you don't want a license, just delete the contents of the LICENSE file after generating the project. Defaults to GPL v3.

Next steps

Your newly generated project has its own README.md, which has the next steps for compiling, linking and running the tests. There are also some useful resources linked in there on TDD, software craftsmanship and code katas to try out.

Happy coding !

cookiecutter-kata-gtest's People

Contributors

kjivan avatar klutz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mapje71

cookiecutter-kata-gtest's Issues

Invalid character in path

The folder {{ cookiecutter.kata|lower }} has a vertical bar, not allowed in windows filesystem so I can't even clone the repo for my own fork.

There are better ways to ensure this folder is in lower case; based on example from documentation:

"kata": {{ cookiecutter.kata }}
"kata_lower": "{{ cookiecutter.kata|lower }}"

Allow license choice

Allow for common open source licenses to be selected during generation, default to GPL3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.