Why do I get the message "Error: Class 'MyClassPartialTests' is not a test"?

I have several unit/logic test classes in my project, and I can run most of them individually (right-click on file and select Run "MyClassTests"), but a couple pop-up a dialog highlighting the test class name in red and showing a message like the following at the bottom of the dialog (where I almost did not see it):

     Error: Class 'MyClassPartialTests' is not a test

Both the test classes that can be run individually and the ones that give the error are subclasses of a class that is a subclass of SenTestCase.  They are also all members of my Logic Tests target, and they all run, when I run/test that target (in AppCode and XCode).

Initially I thought that the only difference between the test classes that can be run individually and the ones that cannot is that the name of the test class is not just the name of the class being tested with "Tests" appended, they include additional text (e.g. MyClassPartialTests instead of just MyClassTests), because I split the tests for this class into multiple test classes.  That is not the issue, because I have another test class named similarly, for the same class under test, that does run individually.



What is AppCode looking for when it reports that a class is not a test class?
5 comments
Comment actions Permalink

Wesley,

AppCode checks the class hierarchy and looks for SenTestCase or GHTestCase as a parent class.
If it doesn't find such, it reports an error.

I did not understant your situation from the description. Can you create a bug report and attach a sample project?

Thanks,
Anton Makeev

0
Comment actions Permalink

Hi Anton,

Here is a clarification.  I am testing Core Data model classes, so I have a parent class for all of my test classes that handles the setup and tear down of the Core Data environment for each test.  Here is an example of the type of test class hierarchy that I have.

--- MyClassTests.h ---
@interface MyClassTests : BaseCoreDataTestCase {

}
@end


--- MyClassComplexMethodTests.h ---
@interface MyClassComplexMethodTests : BaseCoreDataTestCase {
}
@end


--- MyClassAnotherComplexMethodTests.h ---
@interface MyClassAnotherComplexMethodTests : BaseCoreDataTestCase {

}
@end



--- BaseCoreDataTestCase.h ---

@interface BaseCoreDataTestCase : SenTestCase {
}
@end



Some of the test classes (for example MyClassComplexMethodTests) can be run individually, but others (like MyClassTests MyClassAnotherComplexMethodTests) produce the "Edit configuration" dialog with the message at the bottom that the class is not a test.  As you can see, they all have the same class hierarchy, except for the final child class.  I was expecting that the class hierarchy would be used, to determine if a class is a test class, as you stated, which is why I am confused.

To run an individual test class, I typically right-click on the file (.m or .h) in the Project panel or the class file's editor tab, and select Run "MyClassTests", or I use CTRL-SHIFT-R with the test class in the editor, and they all produce the same result as you would expect.


I also tried invalidating caches and restarting (in case it was a cached), but the behavior is still the same.

I will create a bug report and attach a sample project as you requested.

Wes
0
Comment actions Permalink

Wesley,
thanks for the information, we'll investigate.

0
Comment actions Permalink

Hi Anton,

As I was preparing for the bug submission, I was able to identify what appears to be part of the cause of this issue.

In some of my test class implementation files, I was using an unnamed category in my implementation file to declare "private" properties on the test class.  Apparently this unnamed category confuses AppCode, since it is defined with an @interface keyword also.  See example below.

--- MyClassTests.h ---
@interface MyClassTests : BaseCoreDataTestCase {
}
@end

--- MyClassTests.m ---
// An unnamed category
@interface MyClassTests()
// Declared "private" properties
@end

@implementation MyClassTests
// Test methods
@end

This is not the only thing that causes the issue, because I do not see the issue on a new project with this same class structure, but if I remove the category from the implementation (.m) file on the project that does show the issue, then I can run the test class indvidually, and putting the category back causes it to give the dialog with the error message again.

Wes

0
Comment actions Permalink

Hi Anton,

I submitted this as an issue: OC-2824 

Thank you for your help.

Wes

0

Please sign in to leave a comment.