IC2+WS does not allow to run test on a single class

Issue #1109 resolved
Wacław S. created an issue

Hi Whenever I'm trying to run test from one single class, IC2 claims that "No tests were found/Empty test suite". - When I run All Tests (All Tests checkbox in Run/Debug Configuration window), this class is skipped - When I run All Tests from Dev Console - it works, tests are run and pass

What I tried: - Invalidate cache and restart from File Menu - Rebuild Caches and Indices from Project Configuration - Regenerate Full offline symbol table - Multiple restarts, re-deploys, refreshes/retrievals of metadata

Nothing helps :/ Every other class works fine. Any pointers?

IC2 on WebStorm 2018.1.6 #WS-181.5540.11, both licensed.

Comments (15)

  1. Wacław S. reporter

    Here's log content:

    #!
    
    2018-09-11 15:23:03,109 [2797524]   INFO - lij.diagnostic.DebugLogManager - Set DEBUG for the following categories: #com.illuminatedcloud.intellij.unittest.ApexUnitTestRunProcessHandler, #com.illuminatedcloud.util.VariableLengthPollingInterval 
    2018-09-11 15:23:11,355 [2805770]  DEBUG - .ApexUnitTestRunProcessHandler - Running tests for [ illuminated: { TenancyTransactionsFetcherTest } ]. 
    2018-09-11 15:23:11,384 [2805799]  DEBUG - .ApexUnitTestRunProcessHandler - Starting test run. 
    2018-09-11 15:23:11,384 [2805799]  DEBUG - .ApexUnitTestRunProcessHandler - Finding class declaration for TenancyTransactionsFetcherTest. 
    2018-09-11 15:23:11,385 [2805800]   WARN - .ApexUnitTestRunProcessHandler - TenancyTransactionsFetcherTest is not a test class. 
    2018-09-11 15:23:11,385 [2805800]  DEBUG - .ApexUnitTestRunProcessHandler - Creating a trace flag. 
    2018-09-11 15:23:12,626 [2807041]   INFO - .ApexUnitTestRunProcessHandler - Running unit tests synchronously. 
    2018-09-11 15:23:12,626 [2807041]  DEBUG - .ApexUnitTestRunProcessHandler - Starting the test run skipping coverage. 
    2018-09-11 15:23:12,628 [2807043]  DEBUG - .ApexUnitTestRunProcessHandler - Posting the following to runTestsSynchronous: 
    2018-09-11 15:23:12,628 [2807043]  DEBUG - .ApexUnitTestRunProcessHandler -   {"tests":[],"skipCodeCoverage":true} 
    2018-09-11 15:23:12,950 [2807365]   WARN - .ApexUnitTestRunProcessHandler - Unexpected status code 403 returned. 
    2018-09-11 15:23:12,951 [2807366]  DEBUG - .ApexUnitTestRunProcessHandler - Finishing test run. 
    2018-09-11 15:23:47,867 [2842282]   INFO - ide.actions.ShowFilePathAction - 
    Exit code 1 
    

    So it seems it does not recognize TenancyTransactionsFetcherTest class as test class

    It's declared as follows:

    @IsTest
    public with sharing class TenancyTransactionsFetcherTest {
    
  2. Scott Wells repo owner

    Thanks. That helps. Can you tell me more about that class, in particular, is it found under a configured source root in WebStorm? If it's sitting in the same directory as all the other Apex classes, then the answer is yes. I've just seen this in one case before where a user had created a separate directory for test classes but didn't register that directory as a source root with the IDE.

  3. Wacław S. reporter

    This class lays in src/classes, like any other in my project. No noticeable difference between this class and other ones, unfortunately.

  4. Scott Wells repo owner

    Okay, and all of your other test classes run fine, correct? It's just this one that's behaving like this? Or is it more endemic than that?

    Also, do you mind emailing me your full idea.log right after reproducing this? I want to see if there's anything prior to this in the log that might be causing the issue.

  5. Wacław S. reporter

    Hi Scott Yes, only this one class behaves like this. All other work fine.

    I attached to this thread a idea.log from cold start to an attempt of running those tests. Nothing else was done, class was already opened as part of project "state".

    By the way - the same class from the same repository runs fine on my colleague's WS+IC2.

  6. Scott Wells repo owner

    Do you happen to have another class in your project with the exact same name? Or perhaps generated into the offline symbol table? I'm wondering if it's finding more than one class with that name and isn't sure how to resolve the ambiguity.

  7. Wacław S. reporter

    No, it's the only one. TenancyTransactionsFetcher + TenancyTransactionsFetcherTest. There's even no non-class items with such name, like lightning JS controllers, pages, etc. Also name is pretty distinctive, not like "TestUtil" :).

  8. Scott Wells repo owner

    Sorry, I wasn't clear about the ways in which this could happen. Sometimes the IDE itself will copy your source files into an out directory which, unless excluded, can cause duplicates. Also, IC itself can cause this because it generates offline symbol table stubs for custom Apex classes which are in the org but not local, then if you pull those classes to be local, you can end up with one copy in the OST and one locally. I wasn't necessarily implying that you might have two classes with this name in your own project.

    Just to rule this out completely, could you use the Navigate>Class function and type in the name TenancyTransactionsFetcher with Include non-project items checked just to verify that it shows only one match (excluding the corresponding unit test class)? If that doesn't do it, I'll need to instrument with some additional debug logging to help determine why it's unable to find this test class when trying to execute it. Thanks!

  9. Wacław S. reporter

    Hi Scott

    Thanks for your interest.

    classes-2.png

    Only OfflineSymbolTable.zip aside from actual classes and meta files.

    FYI: I re-created the project from scratch (from GIT) and this class works fine now.

  10. Scott Wells repo owner

    Yep, that's the problem. Notice that the class is included in both your local project and in the offline symbol table. Regenerating the OST fixed this issue because, as it generates, it will omit any class that is found locally. So I'm glad this is working properly for you now, but I definitely need to make it handle this situation more gracefully by choosing the local file when the named type is also found in the OST. I'll take care of that for an upcoming build.

  11. Log in to comment