My Ranorex test case would not exit, and the culprit was...

Experiences, small talk, and other automation gossip.
User avatar
Stub
Posts: 322
Joined: Fri Jul 15, 2016 1:35 pm

My Ranorex test case would not exit, and the culprit was...

Post by Stub » Mon Jan 27, 2020 3:58 pm

So I've been writing Ranorex tests for our product(s) for a few years now, hence quite confident in what I'm doing nowadays. Wrote a test case on Friday, then while verifying it I started noticing Ranorex wasn't exiting the test run cleanly. Something funky on my machine, maybe? I hadn't seen this problem before so I decided to come back to it afresh after the weekend.

Today, Monday, I confirmed it was reproducible. Ranorex would get to the end of the test run and just pause indefinitiely. It wouldn't return control to Ranorex Studio, and sometimes I'd lose all control over my mouse. I was having to hit Alt+F4 to break the lock-up. Sometimes this would close Ranorex Studio after it asked if I wanted to end the debugger. Sometimes it'd attempt to close the AUT, and this would be enough to cause Ranorex to break the debug session and finish up, so I could review the report.
  • Couldn't see what was wrong in the Ranorex report; it got to the end of the test case and stalled completely, until interrupted via Alt+F4.
  • Narrowed it down to a particularly problematic test case.
  • Recreated it as a new test case with just the core ingredients that reproduced the lock-up.
  • Noticed that it only occured if I closed then restarted the AUT.
  • Spent a while investigating Repository cache refreshes, but all seemed to be okay.
  • Sometimes if I waited long enough I'd see a curious warning about a message box dialog.
  • In console mode I could see that the logger was shutting down and then restarting with this curious warning.
  • Eventually I started looking at some PopupWatcher-based code.
:
  • And finally the penny dropped.
I'd fired up a PopupWatcher without realising it. I thought it was an 'inline' or sequential (non-PopupWatcher-based, I mean) check for a potential alert that occured on the main test thread and continued if the alert didn't show up. I had utterly forgotten that I'd experimented with PopupWatchers a few years ago when I first started on my Ranorex adventure. I don't use them nowadays. So I'd assumed this code module worked the sequential way. I hadn't checked it.

Seems like stopping and restarting the AUT without cleaning up the PopupWatcher thread was completely borking everything. As soon as I recoded this errant PopupWatcher-based code module to work the way I had expected it to, the problem immediately went away.

Lesson learned.

Took a while but got to the bottom of it in the end. I immediately reviewed all my other PopupWatcher-based experiments and deleted them from our Ranorex code-base so that they don't confuse the next person that falls into this little gotcha.