Running test from the code panel

0 views
Skip to first unread message

Hernan Wilkinson

unread,
May 6, 2009, 1:01:55 PM5/6/09
to omnibro...@googlegroups.com
Hi, 
 I'd like to run a test case as soon as I finish typing it. Right now I have to go to the method list and press alt-t  (or select the option run test)
 I'd like to run the test pressing alt-t in the code panel. It should save the method and the run it. I added a new action to CmdActions in OBTextMorphEditorWithShout but I don't like that because I want it to work as if I have pressed alt-t on the method list (I want the red or green dot to appear). So I created a subclass of OBCommand (similar to OBCmdTestMethod) but I can not make it work when I press alt-t in the code panel. How could I do that?

David Röthlisberger

unread,
May 6, 2009, 4:40:46 PM5/6/09
to omnibro...@googlegroups.com
Hi Hernan,

The simplest solution is to reuse OBCmdTestMethod.

When #executeTest is the method you defined in CmdActions for alt-t, then you can write:

executeTest
| target requestor |
requestor := model browser navigationPanel columns last.
target := model browser currentOrRootNode.
(OBCmdTestMethod on: target for: requestor) execute.
^true

This should do it when you need this action just for test methods.
Maybe you should also check whether target is indeed a test method.

David

Denis Kudriashov

unread,
May 6, 2009, 5:43:50 PM5/6/09
to omnibro...@googlegroups.com
Hi,

I do some another stuff: test button like VW browser "run test button". I dont remember how, but it was really simple, maybe just overriding some method on OBCmdTestMethod. And test button appears only on test method, or category/class/package that contains tests.

See how senders and implementors buttons appear on buttons pane.

Also I want debug and step buttons like in VW but I not found this stuff. :(

Best regards,
Denis


2009/5/6 Hernan Wilkinson <hernan.w...@gmail.com>

Hernan Wilkinson

unread,
May 7, 2009, 8:49:04 AM5/7/09
to omnibro...@googlegroups.com
Hi David,
 thanks for the code but I wanted to do it as a command... I mean, I'd like to define a class similar to OBCmdTestMethod and get the #execute message sent to instances of it when I press alt-t on the code panel. The problem I have is that I can not make the browser to look for commands when a key is pressed on the code panel.
 If I add the keystroke to the class variable CmdActions, then I have to define a message in code panel class (something like the one you just wrote). That is what I did but I thought that having a command was more "omni browser oriented".
 So, maybe I have to change my question.... is there a way to execute a command when a special key get pressed on the code panel? or the only way is to define that key in CmdActions?

David Röthlisberger

unread,
May 7, 2009, 4:49:55 PM5/7/09
to omnibro...@googlegroups.com

> So, maybe I have to change my question.... is there a way to execute a
> command when a special key get pressed on the code panel? or the only
> way is to define that key in CmdActions?

Unfortunately yes. So far there is no direct support in OB for key actions in the
code panel, just in column lists.
We could add such support though. But for the moment we have to live with CmdActions
and stuff, sorry.

David

Hernan Wilkinson

unread,
May 7, 2009, 6:38:49 PM5/7/09
to omnibro...@googlegroups.com
Ok! no problem! I just wanted to be sure I was doing the right stuf

Thanks
Hernan

Colin Putney

unread,
May 8, 2009, 3:55:51 AM5/8/09
to omnibro...@googlegroups.com
Hernan Wilkinson wrote:
> Hi,
> I'd like to run a test case as soon as I finish typing it Right now I

> have to go to the method list and press alt-t (or select the option run
> test)
> I'd like to run the test pressing alt-t in the code panel. It should
> save the method and the run it. I added a new action to CmdActions
> in OBTextMorphEditorWithShout but I don't like that because I want it to
> work as if I have pressed alt-t on the method list (I want the red or
> green dot to appear). So I created a subclass of OBCommand (similar
> to OBCmdTestMethod) but I can not make it work when I press alt-t in the
> code panel. How could I do that?

Hi Hernan,

The tricky bit here is that in the code panel you're dealing with text,
not the nodes of the navigation graph. So all the commands appear in the
code pane menu operate on the current text selection, rather than the
currently selected node.


If you want to have your command be included in the text menu, simply
override OBCommand class>>wantsText. To implement #execute, you'll have
to get the current node from the command's requestor, since the
command's target will be an OBTextSelection.

Hope this helps,

Colin

David Röthlisberger

unread,
May 8, 2009, 8:57:17 AM5/8/09
to omnibro...@googlegroups.com

> If you want to have your command be included in the text menu, simply
> override OBCommand class>>wantsText. To implement #execute, you'll have
> to get the current node from the command's requestor, since the
> command's target will be an OBTextSelection.

To get the command included in the text menu, this works, but triggering the command
execution with a key stroke is not possible from a text panel. At least me couldn't
find a way.

David

Hernan Wilkinson

unread,
May 8, 2009, 12:18:12 PM5/8/09
to omnibro...@googlegroups.com
Hi Colin!
 I saw that, but I want to run the test with out selecting text... just alt-t

Hernan Wilkinson

unread,
May 8, 2009, 12:18:43 PM5/8/09
to omnibro...@googlegroups.com
that's right...
Reply all
Reply to author
Forward
0 new messages