我的appengine SDK放在~/Applications/google_appengine中
在Eclipse中,我已经设置了一个外部工具来运行开发服务器。它指向:
~/Application/google_appengine/dev_appserver.py
同样在Eclipse (Go Preferences)中,我已经将GOROOT设置为指向
~/应用程序/google_appengine/goroot
现在,我正在尝试为我的项目运行一些单元测试。如果我使用常规的go安装(不是appengine安装),我会得到这个错误:
../../context/context.go:4:2: cannot find package "appengine" in any of:
/usr/local/go/src/pkg/appengine (from $GOROOT)
/Users/home/src/go/foodbox/src/appengine (from $GOPATH)
../../context/data.go:4:2: cannot find package "appengine/datastore" in any of:
/usr/local/go/src/pkg/appengine/datastore (from $GOROOT)
/Users/home/src/go/foodbox/src/appengine/datastore (from $GOPATH)
../../context/context.go:5:2: cannot find package "appengine/user" in any of:
/usr/local/go/src/pkg/appengine/user (from $GOROOT)
/Users/home/src/go/foodbox/src/appengine/user (from $GOPATH)如果我使用appengine go,我会得到这个:
load cmd/cgo: package cmd/cgo: no Go source files in /Users/home/Application/google_appengine/goroot/src/cmd/cgo默认安装似乎找不到appengine包(我猜这并不奇怪)。当我使用appengine go工具时,我不确定问题是什么。有没有人能告诉我怎么才能让它工作?
谢谢!
发布于 2013-11-04 21:19:09
值得一提的是,appengine/aetest包现在包含在SDK since 1.8.6中。请参阅documentation。
基本上,您得到了一个可以在测试中使用的appengine.Context,类似于icub3d/appenginetesting。
引用文档中的示例:
import (
"testing"
"appengine/aetest"
)
func TestMyFunction(t *testing.T) {
c, err := aetest.NewContext(nil)
if err != nil {
t.Fatal(err)
}
defer c.Close()
// Run code and tests requiring the appengine.Context using c.
}发布于 2014-10-04 02:47:09
https://stackoverflow.com/questions/17168653
复制相似问题