我可能会以完全错误的方式解决这个问题,但是如何将动态变量传递给SoapUI中相同测试套件中的一堆请求?
我的第一个测试步骤是Groovy脚本.我需要生成一个随机帐户名,然后在我的所有其他请求中使用它.还有大约20个其他请求.我最初认为我可以循环测试套件,但它不起作用.
这是我开始时的groovy脚本:
Random random = new Random()
def randUserAccount = "testAccount"
int max = 100000
randnum = random.nextInt(max+10000)
randUserAccount += randnum
log.info " Creating account: $randUserAccount"
Run Code Online (Sandbox Code Playgroud)
然后在每个请求步骤中,我有这样的事情:
<ns:CreateAccountRequest>
<accountID>${randUserAccount}</accountID>
...
Run Code Online (Sandbox Code Playgroud)
要么
<ns:PurchaseRequest>
<accountID>${randUserAccount}</accountID>
...
Run Code Online (Sandbox Code Playgroud)
当我实际发送它时,该帐户为空,当然这会在服务器端出错.我如何真正让变量在测试套件中的所有请求中持续存在?
提前感谢任何提示!
我必须使用while循环在较大的字符串中找到匹配字符串的所有位置,并使用foreach循环作为第二种方法.我已经找到了while循环方法,但我坚持使用foreach方法.这是'while'方法:
....
my $sequence =
'AACAAATTGAAACAATAAACAGAAACAAAAATGGATGCGATCAAGAAAAAGATGC'.
'AGGCGATGAAAATCGAGAAGGATAACGCTCTCGATCGAGCCGATGCCGCGGAAGA'.
'AAAAGTACGTCAAATGACGGAAAAGTTGGAACGAATCGAGGAAGAACTACGTGAT'.
'ACCCAGAAAAAGATGATGCNAACTGAAAATGATTTAGATAAAGCACAGGAAGATT'.
'TATCTGTTGCAAATACCAACTTGGAAGATAAGGAAAAGAAAGTTCAAGAGGCGGA'.
'GGCTGAGGTAGCANCCCTGAATCGTCGTATGACACTTCTGGAAGAGGAATTGGAA'.
'CGAGCTGAGGAACGTTTGAAGATTGCAACGGATAAATTGGAAGAAGCAACACATA'.
'CAGCTGATGAATCTGAACGTGTTCGCNAGGTTATGGAAA';
my $string = <STDIN>;
chomp $string;
while ($sequence =~ /$string/gi )
{
printf "Sequence found at position: %d\n", pos($sequence)- length($string);
}
Run Code Online (Sandbox Code Playgroud)
这是我的foreach方法:
foreach ($sequence =~ /$string/gi )
printf "Sequence found at position: %d\n", pos($sequence) - length($string);
}
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我为什么它不能以同样的方式工作吗?谢谢!
如果我输入"aaca",我的输出:
Part 1 using a while loop
Sequence found at position: 0
Sequence found at position: 10
Sequence found at position: 17
Sequence found at position: 23
Sequence found …Run Code Online (Sandbox Code Playgroud)