Filter out usages in Tests?

Hello,

     I was wondering if this is a hidden feature I don't know about, or it is under development, or won't be implemented by some reason, or I have to put into some good place, where it could be considered for next releases:

     Simple thing: when you look for usages of some Interface, Property, Method, etc using Alt+F7 (IDEA shortcut), it shows all usages, including all the Unit, Integration and End2End tests which you have in the solution, while in most cases you just need to find how thing is actually used in real code, ignoring all the tests. Yes, tests are green-yellow circles in the tree, so you can "just ignore them", but when your system is tested thoughout, sometimes there is simply too much to ignore, what makes your life harder.

     As a workaround, you can group by project, and not expand those which are your test projects, but I also like "Expand All" button, so it doesn't work well either.

     Simple "ignore usages in tests" checkbox would do it. R# knows if class is a test or not, and hence should be able to filter them out.


     Is it already done? Could it be done if it's not yet? Anyone?


     I am sorry if that was asked in here for 1000 times, but quick search by "filter/hide usages tests" didn't yield any results.

Cheers,
Ivan

3
5 comments

He all,

    Just came up with one more related thing: when I Ctrl+N to find a class, I start typing... and get plenty of tests, and almost no real classes.

    The problem is that we use AAA-style, context-driven tests. It means that we have test classes called something like MyClassUnderTest_when_some_operation_is_performed, and they have methods (tests) like should_do_this, should_not_do_that and so on. Having that on average we've got 7-10 test classes like that per real business class, we end up observing looong lists of classes in Ctrl+N search list, while we only care about just a few there.

    There is already "Include library types" checkbox in the pop-up. It'd be nice if there was another one "exclude test types" checkbox, which does what it says, and remembers last used value.

    What do you think, guys?

Cheers,
Ivan

1

It does exist a similar request "Unused code - ability to specify test class filter" http://youtrack.jetbrains.net/issue/RSRP-80726

1

Hi GreenMoose,

    Nice catch! This is surely similar type of request in the sence that Troy asks for a filtering feature. But he asks for "Unused" code filter, which in his scenario could be rephrased as "Highlight code when it is only used in tests".

    It's quite different thing from what I've been looking for though. First of all, it will not work for our project at all - we use IoC container to create majority of our objects, and we use XML configuration for it. So, if we throw away all the tests, R# will have no way of knowing if class is created and used, or not - there is no code creating it (besides tests). But that's another story. What I'm looking for is simpler manual code inspection: easier way to figure out what are dependencies and relationships in between classes: to find usages in real business code, and navigate to them easily, bypassing walls of references from tests.

    I hope this makes sence.

Ivan


P.S. Luckily enough for Troy (requestor of http://youtrack.jetbrains.net/issue/RSRP-80726 ) R# already knows which class is a test, and which is not, so it won't be a big deal for JetBrains guys to disregard usages from there. However, by the reason I highlighted above, that's quite a dangerous feature. After all, if I was him, I would just unload all of my test projects from solution, and run the analysis - it would show straight away which classes aren't used anymore. (I assume that he doesn't get huge number of classes added and orphaned every day, and that's one-off operation for the project)

0

It makes sense to me... an ability to filter out classes and methods that
are attributed with "Test" attributes would certainly be nice.  Of course,
it would be nice to have a keyboard toggle right in the dialog(s) so you
could easily switch back and forth.

"Ivan Yakovlev"  wrote in message
news:15370256.38911302780147698.JavaMail.devnet@domU-12-31-39-18-36-57.compute-1.internal...

Hi GreenMoose,

    Nice catch! This is surely similar type of request in the sence that
Troy asks for a filtering feature. But he asks for "Unused" code filter,
which in his scenario could be rephrased as "Highlight code when it is only
used in tests".

    It's quite different thing from what I've been looking for though. First
of all, it will not work for our project at all - we use IoC container to
create majority of our objects, and we use XML configuration for it. So, if
we throw away all the tests, R# will have no way of knowing if class is
created and used, or not - there is no code creating it (besides tests). But
that's another story. What I'm looking for is simpler manual code
inspection: easier way to figure out what are dependencies and relationships
in between classes: to find usages in real business code, and navigate to
them easily, bypassing walls of references from tests.

    I hope this makes sence.

Ivan

---
Original message URL: http://devnet.jetbrains.net/message/5300526#5300526

0

Another work around I've found is to simply mark your test directory as “excluded” until you want to use them.

0

Please sign in to leave a comment.