2017 bis heute 2016 2015 2014 | 2013 | 2012 | 2011 2010 2009 | 2008 | 2007

(ältere Archiveinträge vor 2007 nicht dargestellt, aber in der Suche enthalten)

Mailingliste - Einträge 2007

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [QF-Test] call public method of application

  • Subject: Re: [QF-Test] call public method of application
  • From: Gregor Schmid <Gregor.Schmid@?.de>
  • Date: 28 Aug 2007 17:49:31 +0200

[I'm taking the liberty of CC-ing the list as this is a very
interesting common question]

Hi Huawei,

eclipse and thus RCP applications have a very complex class loading
mechanism. Jython's import method is limited to classes available on
the CLASSPATH (which eclipse plugins aren't), so you cannot use import
to access your application's classes. However, you do not need to
import any classes, all you need is to get hold of the target object.

You need to ask your developer how you can gain access to the object
on which you need to call a method. The best way to do this is if the
developer connects the object to some SWT component (ideally the
Workbench window, which should always be available) with setData and a
given key.

Then you can use rc.getComponent to get hold of the component and
getData to get your object, e.g.

win = rc.getComponent("WorkbenchWindow")
someobj = win.getData("keyForSomeObj")

Alternatively, you can try to get hold of a ClassLoader that can load
your class and call its loadClass method, e.g. instead of

from org.eclipse.swt.widgets import Tree


win = rc.getComponent("WorkbenchWindow")
Tree = win.getClass().getClassLoader().loadClass("org.eclipse.swt.widgets.Tree")

You can verify that you got the correct class with, for example:

print dir(Tree)

Best regards,

"Huawei Luo" <hluo@?.com> writes:

>    Hi, Greg:
>    There are some very dynamic features in my application, so my developer
>    wrote a method in the application for me to call from a SUT script. I
>    wonder how to make a call to a method of application under test. I can
>    try to use from <package> import <class>, but tried before, and got a
>    "module not defined error". Is this any possible?
>    Thanks and Regards
>    Huawei

Gregor Schmid                                Gregor.Schmid@?.de
Quality First Software GmbH                     http://www.qfs.de
Tulpenstr. 41                                Tel: +49 8171 919870
DE-82538 Geretsried                          Fax: +49 8171 919876
GF: Gregor Schmid, Karlheinz Kellerer          HRB München 140833