Running duration test/long term test/repetiting same test in qtuitestrunner
-
Hi,
I have my simple qtscript file as follows:
@
testcase = {
testFunction1: function() {
startApplication("<path to qml viewer>", ["<path to test.qml>"]);
var close = findWidget( {qmlType: "Rectangle"} );
mouseClick(close);
verify(getLabels().contains("Hello World!"));
}
@
I want to repeat this for 10 times (i.e. opening this application, checking and verifying). when I do this like below
@
testcase = {
for (var i=0; i<10; i++){
testFunction1: function() {
startApplication("<path to qml viewer>", ["<path to test.qml>"]);
var close = findWidget( {qmlType: "Rectangle"} );
mouseClick(close);
verify(getLabels().contains("Hello World!"));
}
}
@
and running this with qtuitestrunner gives an error note
QtUiTest: couldn't listen for connections on 5156 : "The bound address is already in use" started : false
is there any way to solve this problem....
or to define this in the script file so that the whole thing will be repeated many times.Thanks!
BR,
Zaman[edit: code highlighted / Denis Kormalev]
-
Hi mhzaman77, please use tag @ in your post code.
Thank's. -
Put some wait in the loop and check if it helps.
-
Hi,
tag is used.no, putting wait does not help.
Thanks,
Zaman -
[quote author="mhzaman77" date="1292327680"]Hi,
tag is used.
[/quote]
Thank's :P -
[quote author="mhzaman77" date="1292327680"]Hi,
tag is used.no, putting wait does not help.
Thanks,
Zaman[/quote]Where did you put the wait and try. Also if I am understanding it right . You are facing problem when adding the loop part of the code otherwise it works properly.
-
Hi,
Thanks for the quick response. I put the loop after one instant is finished and before starting the 2nd instant as shown below:@
testcase = {
for (var i=0; i<10; i++){
testFunction1: function() {
wait (5000);
startApplication("<path to qml viewer>", ["<path to test.qml>"]);
var close = findWidget( {qmlType: "Rectangle"} );
mouseClick(close);
verify(getLabels().contains("Hello World!"));
wait (5000);
}
}
@still it is the same. Can u please correct me....
Yes, in general works fine when there is no loop introduced.BR,
Zaman -
To me it seems like something is not closed properly. Check once you start qmlviewer it is closed properly before starting it again in the loop.
-
Hi,
yes, without putting the loop - qmlviewer process is closed.Having the loop - I was thinking once the application is opened, then checking and after verification if there is some command to close the application which might help before initiating the next loop. - so far no clue....
BR,
Zaman -
Hi,
guessing if there is any cleanup function to be used and how to...BR,
Zaman -
That's why I wanted to check if putting some wait helped and provided enough time to close the application. Any clue why with loop it didnt close
-
Hi Zaman,
You have put the for loop outside the test function definition. If you put it inside testFunction1, does it work?
I tried the following, which is similar to what I think you’re trying to do, and it works OK. This uses the photoviewer demo (note, the QTDIR and QT_SRC environment variables need to be set for this to run).
@testcase = {
photoviewer: function() {
for (var i=0; i<10; i++) {
startApplication("$QTDIR/bin/qmlviewer", ["$QT_SRC/demos/declarative/photoviewer/photoviewer.qml"]);
mouseClick("Quit");
}
}
}@Cheers,
David -
Hi David,
Thanks for the hints.
For this specific photoviewer application there is a quit button which closes the application before it enters into the for loop for the 2nd instance. And it works fine.
Now if you comment (//mouseClick ("Quit") - looping the appl. does not work. Gives an error note:
QDEBUG : test::photoviewer(...) QtUiTest: couldn't listen for connections on 5656 : "The bound address is already in use" started : falsefor my application also it shows animated 'Hello world' text. After having a mouse click it changes the position. In test script after the application is opened - I guess I need to close this instant of appl. run before it goes for 2nd instant. i.e.
@
testcase = {
testFunction1: function() {
for (var i=0; i<10; i++){
startApplication("<path to qml viewer>", ["<path to test.qml>"]);
var close = findWidget( {qmlType: "Rectangle"} );
mouseClick(close);
verify(getLabels().contains("Hello World!"));
wait (5000);
// I guess I need to use some command/api to close the current run of the application before it enters into the loop for 2nd run
}
}
}
@Many Thanks.
BR,
Zaman -
Hi David,
one update:
also the way tried as shown below does not work:
@
testcase = {
photoviewer: function() {
for (var i=0; i<3; i++) {
startApplication("qmlviewer", ["photoviewer.qml"]);
wait(1000);
enter("Brisbane", "Prague");
select("Add");
wait(1000);
enter("Oslo", findByProperty({ text: "" }));
select("Edit");
wait(1000);
var removeButton = findByProperty({ label: "Remove" });
for (var i=0; i<4; ++i) {
select(removeButton[i]);
}mouseClick("Quit");
}}
}
@Thanks.
BR,
Zaman -
I was able to reproduce the problem, and I'll take a look at how to fix it. In the meantime, it is possible to use the test data mechanism to repeatedly run a test function.
The test data for each test function is just a JavaScript object, so it can be set using code. For example, this runs the photoviewer test function 20 times:
@testcase = {
photoviewer_data: {},photoviewer: function() { startApplication("$QTDIR/bin/qmlviewer", ["$QT_SRC/demos/declarative/photoviewer/photoviewer.qml"]); print(getLabels()); }
}
for (var i=0; i<20; i++) {
eval("testcase.photoviewer_data.run" + i + " = []");
}@Hope this helps!
David -
Hi David,
That`s great. Yes, test data mechanism works fine.
BR,
Zaman