17

I'd like to write some Python unit tests for my Google App Engine. How can I set that up? Does someone happen to have some sample code which shows how to write a simple test?

oneself
  • 38,641
  • 34
  • 96
  • 120
  • See http://stackoverflow.com/questions/107675/how-can-i-unit-test-responses-from-the-webapp-wsgi-application-in-google-app-engi – Dave W. Smith May 01 '10 at 17:57

4 Answers4

18

GAEUnit is a unit test framework that helps to automate testing of your Google App Engine application.

Update: The Python SDK now provides a testbed module that makes service stubs available for unit testing. Documentation here.

jbochi
  • 28,816
  • 16
  • 73
  • 90
3

Google's Python SDK now allows for this via the unittest module. More details here.

One note that you might find useful: To actually execute the tests, you should use NoseGAE. From the commandline, use:

$ sudo easy_install nose
$ sudo easy_install NoseGAE

(you can alternatively use pip for a virtual environment installation)

Then cd into your app's source directory and run:

$ nosetests --with-gae

That will run all the unit tests for your app.

gabor
  • 4,281
  • 8
  • 24
  • 20
2

One working solution is using following combination (as described in http://www.cuberick.com/2008/11/unit-test-your-google-app-engine-models.html)

  • Nose
  • Nose GAE
  • GAE Testbed
jmu
  • 3,619
  • 1
  • 23
  • 12
1

Since, gae is based on webhooks it can be easy to set your own testing framework for all relevant urls in your app.yaml. You can test it on sample dataset on development server ( start devel server with --datastore_path option ) and assert writes to database or webhook responses.

Bojan Babic
  • 605
  • 5
  • 19