JUnit question

Jacques, I'm not sure whether these are bugs or features:
- in a generated test class all test (public) methods have the "create test"
gutter icons - it looks messy to offer generating tests for tests
- the icons actually, don't generate anything, but jump to the original methods.
I like that, but the icon and text could be different.
- while I like the icon to jump to the source method, I don't see similar one
FROM source to test. That would be nice.
- hm.... after doing some work, the icon in the test class doesn't jump to the
source anymore. Strange. Now it tries to create a test method (as the icon says)
and fails because this is test class.
- is there a shortcut to jump from test method to source?

Thanks

r.

9 comments

- is there a shortcut to jump from test method to source?


See Go To/Test(ed) class. Not sure what the default key is (I remaped it
long ago), but you can find it in Main Menu/Go To section in the keymap
setting. And it jumps both ways. :)

HTH,
Andrei


0

Well, I have Ctrl-Shft-T Go to Test class and that really gets me to the
test class/method. But don't have the opposite one. The icon, Ctrl-Shft-T
and the menu action - all try to add test to the test method (and fail).
It seems like it doesn't recognize the test class as test class.

Could that be because I have several modules? Or any other idea?

Thanks

r.


Andrei Oprea wrote:

>>- is there a shortcut to jump from test method to source?


See Go To/Test(ed) class. Not sure what the default key is (I remaped it
long ago), but you can find it in Main Menu/Go To section in the keymap
setting. And it jumps both ways. :)

HTH,
Andrei

0

OK, I didn't realize that I may have to restart IDEA, so the jumping
works for me, now.
What I still don't have, is once I generate a test method how can I
generate the other one? (e.g. the exception test)

r.

Richard Nemec wrote:

Well, I have Ctrl-Shft-T Go to Test class and that really gets me to the
test class/method. But don't have the opposite one. The icon, Ctrl-Shft-T
and the menu action - all try to add test to the test method (and fail).
It seems like it doesn't recognize the test class as test class.

Could that be because I have several modules? Or any other idea?

Thanks

r.


Andrei Oprea wrote:

>>> - is there a shortcut to jump from test method to source?
>>
>>
>>
>> See Go To/Test(ed) class. Not sure what the default key is (I remaped it
>> long ago), but you can find it in Main Menu/Go To section in the keymap
>> setting. And it jumps both ways. :)
>>
>> HTH,
>> Andrei
>>
>>

0

Creating the next test is not implemented yet. What I had in mind is when there is already multiple test method, present the list of test methods plus a "Create new test".
I want to support the quick toggle of TDDers:
1. I create a simple test
2. I make it pass
3. I make it more complex
4. I make it pass
5... and so on until the test is satisfactory
For that the menu will default to the last test visited. I was thinking of placing the Create new test just right next to it so to create a new test would be Ctrl-Shift-T + Up + Enter.

As far as having the plugin believe that a test is in fact a class under test, I have seen the behavior as well and I am pretty sure it is because of the multi-module. Unfortunately JetBrains haven't been very helpful here and all my investigation have so far being for naught.
For now I use Ctrl-Shift-T to go to test and Ctrl-Alt-Left to go back ;-(

Sorry

Jacques

0

Well believe it or not but you mentioning it pushed me to look at it another time.
I found my problem. Yep it is because each module has a different representation of junit.framework.TestCase internally. Each is not interchangeable with the others so when the plugin happened to pick up the right one, a test class was correctly identified as such by the plugin. If however the plugin would pick a TestCass representation from another module than the current test class, it would incorrectly take it as a class under test.

Uploading 0.25 now.

Jacques

0

Thanks Jacques. (You may expect more questions and suggestions soon)
r.

0

There is one thing i put in as often i find 3 or 4 methods have been written without tests :-(. In the test case if you use the keys ctrl-shift-alt-m it will pop up a list of methods that are not tested, by selecting one it will add the test method to your test case. Is this what you wanted for "creating next test"?

0

I believe he is talking about creating the next test of the same method.

Jacques

0

Ahh there you go :) i also got the key mapping wrong ctrl-shift-alt-t, maybe it is time for sleep!!

0

Please sign in to leave a comment.