Python - 迭代测试 SOAP 服务;每次迭代需要使用不同的变量
好吧,这是我的场景(友善,只使用 Python 一小段时间):
我有一个正在调用的服务,需要使用传递给该方法的不同变量来运行同一测试的多次迭代。我可以很好地针对单个方法运行迭代,但我需要每个测试都更改变量,并且不计算获取随机变量作为迭代的调用。我可能会以错误的方式处理这个问题,但我希望得到任何帮助。
到目前为止,这是我的代码:
data = ""
class MyTestWorkFlow:
global data
def Data(self):
low = 1
high = 1000
pid = random.randrange(low,high)
data = linecache.getline('c:/tmp/testData.csv', pid)
def Run(self):
client = Client(wsdl)
result = client.service.LookupData(data)
f = open('/tmp/content','w')
f.write (str(result))
f.close()
f = open('/tmp/content','r')
for i in f:
print i
f.close()
test = MyTestWorkFlow()
for i in range(1,2):
test.Run()
Ok here's my scenario (be kind, only been using Python for a short while):
I have a service I'm calling and need to run several iterations of the same test with a different variable passed to the method. I am able to run iterations against a single method just fine but I need the variable to change per each test and without counting the call to get a random variable as an iteration. I'm probably going about this the wrong way but I'd love any help I can get.
Here's my code thus far:
data = ""
class MyTestWorkFlow:
global data
def Data(self):
low = 1
high = 1000
pid = random.randrange(low,high)
data = linecache.getline('c:/tmp/testData.csv', pid)
def Run(self):
client = Client(wsdl)
result = client.service.LookupData(data)
f = open('/tmp/content','w')
f.write (str(result))
f.close()
f = open('/tmp/content','r')
for i in f:
print i
f.close()
test = MyTestWorkFlow()
for i in range(1,2):
test.Run()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关于 Python 中的自动化测试,我们可以讨论很多,但这里的问题是您似乎没有调用
Data
方法。如果您像这样更改代码:
它能满足您的需要吗?
There's a lot we could talk about regarding automated testing in Python, but the problem here is that you don't seem to be invoking your
Data
method.If you change your code like this:
does it do what you need?