Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I go about setting up a TDD development process with Google App Engine?

I'm primarily a Ruby guy, but lately I've been working on a lot of Python stuff, in particular, App Engine code. In Ruby, I'd use automated continuous integration (autotest), code coverage tools (rcov), static analysis (reek), and mutation testing (heckle) in my development process, but I'm not sure how best to set up a similar development process for an App Engine environment. I'd also be interested in analogs to RSpec and Cucumber for Python that could work in App Engine.

like image 712
Bob Aman Avatar asked Oct 20 '09 00:10

Bob Aman


People also ask

Is TDD used in Google?

TDD is a software-development process. You can apply TDD wherever you practice software development, whether it's iOS, Android, back-end, front-end, embedded, etc.

What is the goal of developer TDD?

With developer TDD you write a single developer test, sometimes inaccurately referred to as a unit test, and then just enough production code to fulfill that test. The goal of developer TDD is to specify a detailed, executable design for your solution on a JIT basis. Developer TDD is often simply called TDD.


1 Answers

You won't always find one to one equivalents of Ruby testing tools in Python, but there are some great testing tools in Python. Some of the tools that I've found useful include:

  • unittest - the xUnit tool included in the Python standard library. It includes all the basics for unit testing.
  • doctest - an awesome part of the standard library, it allows you to write tests in the docstrings of functions, classes, modules, methods. It is great at conveying intended API usage. Ian Bicking suggests using doctest for Behavior Driven Development. Doctest fits very well into the Sphinx documentation system (you can make sure all the examples in your documentation pass every time you build the docs).
  • nose and py.test are seen as the next-gen versions of unittest. They can run all existing unittest cases, but allow for easier, non-class based unit tests. py.test also allows for distributed execution.
  • mock is a nice library for mocking behavior.
  • tdaemon watches a directory for updates to your code and will re-execute your test suite. (my personal branch contains a few unmerged improvements).
  • Buildbot, Bitten, and even Hudson all work well as full-fledged continuous integration servers for Python code.
  • coverage.py computes the code coverage of your code.
  • pylint will provide a lint-like analysis of your code, making sure it follows common coding conventions and does not have any common bugs. There is also a "lighter" analysis tool, PyFlakes.
  • There are a number of HTTP / Browser testing tools that work well in Python, including Twill, Selenium, and Windmill.

If you are using Django on App Engine, it includes several extensions to unittest that allow you simulate an HTTP client and database persistence.

There are a ton of other tools that I have not used (such as PySpec and Behaviour) that could also be helpful. I haven't seen any mutation testing tool in Python, but I bet there is one out there (I would love to learn what it is).

Happy testing!

like image 120
John Paulett Avatar answered Sep 23 '22 08:09

John Paulett