How to debug WindowTester tests?

WindowTester allows you to easily create and run unit tests for every GUI they build. It can also be used to generate system level tests.

Moderators: gnebling, Eric Clayberg, Dan Rubel, keertip, Phil Quitslund

How to debug WindowTester tests?

Postby joker » Wed Apr 25, 2007 3:16 am

Hi ... can you tell me about debugging a test? Every time I try, I get an Exception like 'root must not be null'. Of course, I know and I expect that. I switch between Eclipse and the application under test as quick as possible, but every time I'm too late. Unfortunately, changing the delay preferences did not help. What about finderRetries and the other WindowTester runtime settings? Any combination that could help? I set it up to a higher level, but the effect was always the same. Any other suggestions?
Thanks in advance ...
joker
 
Posts: 2
Joined: Mon Apr 16, 2007 4:57 am
Location: Berlin, Germany

Postby Phil Quitslund » Thu Apr 26, 2007 8:59 am

You might give the attached condition a shot. It pops up a VERY crude shell that you can click to get the test to resume. It is limited in the sense that it does NOT handle the case where a modal shell (such as a dialog) is blocking the UI thread, but it's a start!

Let me know if this is helpful at all --- and if you improve it, please share your improvements!



Code: Select all
package com.windowtester.runtime.swt.util;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

import com.windowtester.runtime.condition.ICondition;


/**
*
* Halts test until "Resume Test" button is pushed.
* <p>
* Example use:
* <pre>
*   ... ui actions
*   ui.wait(new ResumeCondition()); //pause to debug...
* </pre>
* <p>
* Note: the current implementation cannot pause while modal dialogs are blocking the UI thread.
* <p>
* Copyright (c) 2007, Instantiations, Inc.<br>
* All Rights Reserved
*
* @author Phil Quitslund
*
*/
public class ResumeCondition implements ICondition {

   private Shell _shell;
   
   /**
    * Create an instance of this condition using the default display.
    */
   public ResumeCondition() {
      this(Display.getDefault());
   }
   
   /**
    * Create an instance of this condition using the specified display.
    */
   public ResumeCondition(final Display display) {
      display.syncExec(new Runnable() {
         public void run() {
            _shell = new Shell(display, SWT.ON_TOP);
            _shell.setLayout(new FillLayout());
            Button resumeButton = new Button(_shell, SWT.PUSH);
            resumeButton.setText("Resume Test");
            resumeButton.addSelectionListener(new SelectionAdapter() {
               public void widgetSelected(SelectionEvent e) {
                  _shell.dispose();
               }
            });
            _shell.pack();
            _shell.open();
         }
      });
   }

   /* (non-Javadoc)
    * @see com.windowtester.runtime.condition.ICondition#test()
    */
   public boolean test() {
      return _shell == null || _shell.isDisposed();
   }
   
   /* (non-Javadoc)
    * @see java.lang.Object#toString()
    */
   public String toString() {
      return "Resume Condition";
   }

}
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Postby joker » Wed May 02, 2007 6:35 am

Thanks for your reply, Phil.
I will test the attached code and I am sure that it is working fine.

However, the ResumeCondition is "only" a better way of putting a breakpoint before a ui.pause(2000); like I did before. Of course, that will help in cases of debugging certain code snippets.
Unfortunately, debugging a whole test case would mean to put a ui.wait(new ResumeCondition()); between every line of code.

How do the others debug their code?
joker
 
Posts: 2
Joined: Mon Apr 16, 2007 4:57 am
Location: Berlin, Germany

Postby Phil Quitslund » Thu May 03, 2007 10:27 am

You're right: if you want to step through the entire test case, the ResumeCondition is a bit cumbersome (beyond it's limitations in modal contexts). This is a tricky problem...

How would you *like* it to work?
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Postby Mac » Tue May 08, 2007 5:33 am

Hi,

I am working together with joker and therefore experienced the same issues.
Maybe it could be handled in this way:

- when starting in debug mode, the "root must not be null" Exception is not thrown.
- instead the UI Thread just sleeps for some milliseconds and tries again, until root != null is true.
- Then the test could be easily debugged, as the UI Thread just hangs at the same line of code, until I switch back to the Application I want to test.

Just an idea.

bye
Mac
 
Posts: 14
Joined: Thu Apr 05, 2007 4:19 am

Postby Phil Quitslund » Tue May 22, 2007 3:03 pm

Excellent idea! Could you send a feature request to support so we can track it?

Thanks!
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am


Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest