I was told the best solution to run unit tests for code that uses App Engine services such as datastore or memcache was to run the development server in a child process, but I'm not sure how. Anybody successfully ran this kind of test and can share a solution?
App Engine SDK for Go uses the Python dev_appserver; see this thread.
Android unit testing For Android, unit tests are compiled to run on the Java Virtual Machine (JVM) to minimize execution time. If your tests depend on objects in the Android framework, you can use Robolectric. For tests that depend on your own dependencies, use mock objects to emulate your dependencies' behavior.
If you want to test concurrency you'll need to make a few go routines and have them run, well, concurrently. You might try taking the locking out and intentionally get it to crash or misbehave by concurrently modifying things and then add the locking in to ensure it solves it.
At the command line in the greetings directory, run the go test command to execute the test. The go test command executes test functions (whose names begin with Test ) in test files (whose names end with _test.go). You can add the -v flag to get verbose output that lists all of the tests and their results.
You should check out Google App Engine Go testing library by Josh Marsh.
An interesting development, as of 1.8.6 using service stubs has been integrated into the SDK through the "appengine/aetest"
package. More info
I know the questioner wants to build a testbed and needs to do this, but I think there's another approach worth mentioning here.
Besides using a testbed for the GAE services, Go's interesting nature also opens up another possibility: write your application to just require objects that have the interfaces that you use (they'd be a subset of the official APIs) and mock them out when testing. This requires you to be doing some amount of dependency injection of some sort, but that's a really good idea anyway.
Once the interfaces the interfaces are written, you can mock them using a library like gomock.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With