pause a test from a thread outside

Class library usage, coding and language questions.
agrimm
Posts: 5
Joined: Wed Jul 24, 2013 1:51 pm
Location: Germany

pause a test from a thread outside

Post by agrimm » Mon Aug 11, 2014 8:16 am

Hi Community,
i have written a piece of code in program.cs to restart the program to test in a thread outside the current test. Now i have the problem, that those restart actions have to be executed completely before the main test continues. Actually both tests are running parallel and it could be, that some actions are failing cause of timeouts.
So it would be nice to pause the main test execution, run the restart actions from inside the thread and then continue with the main test. Is there maybe a Ranorex Funktion available?

Thanks in advance

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: pause a test from a thread outside

Post by Support Team » Wed Aug 13, 2014 9:05 am

Hi agrimm,

Unfortunately Ranorex does not provide a method/action to pause the main thread since Ranorex is designed to run in a single threaded mode. I’m not exactly sure how your tests look like but it shouldn’t be a problem to restart the AUT (Application Under Test) before starting your test, e.g., within the “Program.cs”. Even if your test contains a few steps before restarting your AUT, just shift the “restart”-code snippet to a “UserCodeModule” and call it as a part of your test.

Please feel free to correct me and try to rephrase your question if I’m wrong at any point.

Regards,
Robert

agrimm
Posts: 5
Joined: Wed Jul 24, 2013 1:51 pm
Location: Germany

Re: pause a test from a thread outside

Post by agrimm » Thu Aug 14, 2014 2:39 pm

Hi Robert,
the problem is that i don´t know, when the program crashes (or better, in which iteration of the test). That´s where this thread should watch permanently and restart the program from outside if necessary, so that the (main) ranorex test could continue. An integration into a specified usercode module couldn´t be the right place for that restart routine, right?

Now the actual situation is, that the ranorex test continues with it´s work and runs into timeouts, because the application doesn´t respond (logically..., it´s crashed). That´s why i asked for a pause option in ranorex that i could use to freeze the main process, until the thread has has restarted the program.

Any other thoughts to design such an workarround are welcome.

Many thanks

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: pause a test from a thread outside

Post by krstcs » Thu Aug 14, 2014 2:59 pm

I would suggest that if your AUT is crashing, you should NOT continue the test. How do you guarantee the state/stability of the test after it continues? I don't think you can, and that means the test run becomes invalid because all data points after the crash are suspect.

You should get the crash fixed. Your tests should not be written to take unexpected or abnormal behavior into account unless you are doing specific, negative testing. Even the popup watcher should be used VERY sparingly.

All tests should have known inputs, known actions and expected results. If you are getting crashes, that is an UNEXPECTED result and should not be allowed to continue without being fixed.



One thing you CAN do is to use a Continuous Integration system like Jenkins to run your tests. I have mine setup so that if a test fails in my regression set, the whole set is run 1 more time to make sure it wasn't a transient issue. But even that should be a warning that there is something not right.
Shortcuts usually aren't...

agrimm
Posts: 5
Joined: Wed Jul 24, 2013 1:51 pm
Location: Germany

Re: pause a test from a thread outside

Post by agrimm » Mon Aug 18, 2014 11:46 am

That´s true, normally i would call the test as failed.
But in this case where the test runs over a couple of hours, an exception handling is needed, and the information about the following testcases are still usable.

Since i really got no idea how to react properly, i would log the whole situation in the first place and leave it as it is.

So far, thanks for your comments.