Hi guys, I was just wondering how common it is, since Python is so faster to write and manipulate objects, to use Python instead of Go to exercise HTTP APIs?
评论:
juicemia:
rz2yoj:I wouldn't think it's very common, just because it's not that much easier to do in Python than it is in Go. Sure it's a bit easier, but is it so much easier that it's worth adding another language to a project/projects just to run the tests? I don't think it is.
dsmV:I've certainly never seen it. And the whole "Python being faster for X" thing is a highly subjective statement.
Write your API tests as Go tests, using the standard net/http/httptest package. Then you can share your model types, get code coverage reports, and more.
Funny, I kind of did the inverse. I wrote a go program that outputs a fairly a complicated XML string. I pipe it to a python script which sends it to a SOAP interface. I could probably just as easily write the XML generation in python, but I enjoy writing Go. However, Python has a ridiculously simple package for interacting with SOAP interfaces and I had to mock something up quickly. This was just for systems integration testing, not production by any means.
