Go 1.11 has reached end of support
and will be deprecated
on January 31, 2026. After deprecation, you won't be able to deploy Go 1.11
applications, even if your organization previously used an organization policy to
re-enable deployments of legacy runtimes. Your existing Go
1.11 applications will continue to run and receive traffic after their
deprecation date. We
recommend that you migrate to the latest supported version of Go.
The environment variable APPENGINE_DEV_APPSERVER specifies the location of the
dev_appserver.py executable to use. If unset, the system PATH is consulted.
PrepareDevAppserver is a hook which, if set, will be called before the
dev_appserver.py is started, each time it is started. If aetest.NewContext
is invoked from the goapp test tool, this hook is unnecessary.
NewContext starts an instance of the development API server, and returns
a context that will route all API calls to that server, as well as a
closure that must be called when the Context is no longer required.
Instance
typeInstanceinterface{// Close kills the child api_server.py process, releasing its resources.io.Closer// NewRequest returns an *http.Request associated with this instance.NewRequest(method,urlStrstring,bodyio.Reader)(*http.Request,error)}
Instance represents a running instance of the development API Server.
NewInstance launches a running instance of api_server.py which can be used
for multiple test Contexts that delegate all App Engine API calls to that
instance.
If opts is nil the default values are used.
Options
typeOptionsstruct{// AppID specifies the App ID to use during tests.// By default, "testapp".AppIDstring// StronglyConsistentDatastore is whether the local datastore should be// strongly consistent. This will diverge from production behaviour.StronglyConsistentDatastorebool// SupportDatastoreEmulator is whether use Cloud Datastore Emulator or// use old SQLite based Datastore backend or use default settings.SupportDatastoreEmulator*bool// SuppressDevAppServerLog is whether the dev_appserver running in tests// should output logs.SuppressDevAppServerLogbool// StartupTimeout is a duration to wait for instance startup.// By default, 15 seconds.StartupTimeouttime.Duration}
Options is used to specify options when creating an Instance.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-03 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eaetest\u003c/code\u003e package provides an API for running the \u003ccode\u003edev_appserver\u003c/code\u003e within tests, enabling developers to simulate the App Engine environment.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eNewContext\u003c/code\u003e initializes a development API server instance, returning a context for API calls and a closure for cleanup when the context is no longer needed.\u003c/p\u003e\n"],["\u003cp\u003eThe environment variable \u003ccode\u003eAPPENGINE_DEV_APPSERVER\u003c/code\u003e can be set to specify the location of the \u003ccode\u003edev_appserver.py\u003c/code\u003e executable; otherwise, the system PATH is used.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eNewInstance\u003c/code\u003e allows the launching of a persistent \u003ccode\u003eapi_server.py\u003c/code\u003e instance for multiple test contexts to share, using \u003ccode\u003eOptions\u003c/code\u003e to customize the instance's behavior, such as App ID and datastore consistency.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eLogin\u003c/code\u003e and \u003ccode\u003eLogout\u003c/code\u003e functions are provided to simulate logged-in and logged-out users respectively, useful for testing user-specific behaviors within requests.\u003c/p\u003e\n"]]],[],null,["# Package google.golang.org/appengine/aetest (v1.6.7)\n\nVersion 1.6.7keyboard_arrow_down\n\n- [1.6.8 (latest)](/appengine/docs/legacy/standard/go111/reference/latest/aetest)\n- [1.6.7](/appengine/docs/legacy/standard/go111/reference/1.6.7/aetest) \n**Note:** To get more information about this package, such as access to older versions, view [this package on pkg.go.dev](https://pkg.go.dev/google.golang.org/appengine/aetest). \n\u003cbr /\u003e\n\nPackage aetest provides an API for running dev_appserver for use in tests.\n\nAn example test file: \n\n```python\npackage foo_test\n\nimport (\n \"testing\"\n\n \"google.golang.org/appengine/memcache\"\n \"google.golang.org/appengine/aetest\"\n)\n\nfunc TestFoo(t *testing.T) {\n ctx, done, err := aetest.NewContext()\n if err != nil {\n t.Fatal(err)\n }\n defer done()\n\n it := &memcache.Item{\n Key: \"some-key\",\n Value: []byte(\"some-value\"),\n }\n err = memcache.Set(ctx, it)\n if err != nil {\n t.Fatalf(\"Set err: %v\", err)\n }\n it, err = memcache.Get(ctx, \"some-key\")\n if err != nil {\n t.Fatalf(\"Get err: %v; want no error\", err)\n }\n if g, w := string(it.Value), \"some-value\" ; g != w {\n t.Errorf(\"retrieved Item.Value = %q, want %q\", g, w)\n }\n}\n```\n\n\u003cbr /\u003e\n\nThe environment variable APPENGINE_DEV_APPSERVER specifies the location of the\ndev_appserver.py executable to use. If unset, the system PATH is consulted. \n\nVariables\n---------\n\n### PrepareDevAppserver\n\n var PrepareDevAppserver func() https://pkg.go.dev/builtin#error\n\nPrepareDevAppserver is a hook which, if set, will be called before the\ndev_appserver.py is started, each time it is started. If aetest.NewContext\nis invoked from the goapp test tool, this hook is unnecessary. \n\nFunctions\n---------\n\n### func Login\n\n func Login(u *https://pkg.go.dev/google.golang.org/appengine/user.https://pkg.go.dev/google.golang.org/appengine/user#User, req *https://pkg.go.dev/net/http.https://pkg.go.dev/net/http#Request)\n\nLogin causes the provided Request to act as though issued by the given user. \n\n### func Logout\n\n func Logout(req *https://pkg.go.dev/net/http.https://pkg.go.dev/net/http#Request)\n\nLogout causes the provided Request to act as though issued by a logged-out\nuser. \n\n### func NewContext\n\n func NewContext() (https://pkg.go.dev/golang.org/x/net/context.https://pkg.go.dev/golang.org/x/net/context#Context, func(), https://pkg.go.dev/builtin#error)\n\nNewContext starts an instance of the development API server, and returns\na context that will route all API calls to that server, as well as a\nclosure that must be called when the Context is no longer required. \n\nInstance\n--------\n\n type Instance interface {\n \t// Close kills the child api_server.py process, releasing its resources.\n \thttps://pkg.go.dev/io.https://pkg.go.dev/io#Closer\n \t// NewRequest returns an *http.Request associated with this instance.\n \tNewRequest(method, urlStr https://pkg.go.dev/builtin#string, body https://pkg.go.dev/io.https://pkg.go.dev/io#Reader) (*https://pkg.go.dev/net/http.https://pkg.go.dev/net/http#Request, https://pkg.go.dev/builtin#error)\n }\n\nInstance represents a running instance of the development API Server. \n\n### func NewInstance\n\n func NewInstance(opts *#google_golang_org_appengine_aetest_Options) (#google_golang_org_appengine_aetest_Instance, https://pkg.go.dev/builtin#error)\n\nNewInstance launches a running instance of api_server.py which can be used\nfor multiple test Contexts that delegate all App Engine API calls to that\ninstance.\nIf opts is nil the default values are used. \n\nOptions\n-------\n\n type Options struct {\n \t// AppID specifies the App ID to use during tests.\n \t// By default, \"testapp\".\n \tAppID https://pkg.go.dev/builtin#string\n \t// StronglyConsistentDatastore is whether the local datastore should be\n \t// strongly consistent. This will diverge from production behaviour.\n \tStronglyConsistentDatastore https://pkg.go.dev/builtin#bool\n \t// SupportDatastoreEmulator is whether use Cloud Datastore Emulator or\n \t// use old SQLite based Datastore backend or use default settings.\n \tSupportDatastoreEmulator *https://pkg.go.dev/builtin#bool\n \t// SuppressDevAppServerLog is whether the dev_appserver running in tests\n \t// should output logs.\n \tSuppressDevAppServerLog https://pkg.go.dev/builtin#bool\n \t// StartupTimeout is a duration to wait for instance startup.\n \t// By default, 15 seconds.\n \tStartupTimeout https://pkg.go.dev/time.https://pkg.go.dev/time#Duration\n }\n\nOptions is used to specify options when creating an Instance."]]