Quantcast
Channel: JetBrains Developer Community : Thread List - IntelliJ IDEA Users
Viewing all articles
Browse latest Browse all 5661

Java Annotations: expected array instead of object

$
0
0

Hello everyone,

 

I'm a former Eclipse user who wants to get started with IntelliJ IDEA. I'm currently facing an issue that really bugs me.

 

Assume you have a Unit Test Suite:

 

@RunWith(Suite.class)
@SuiteClasses({Test1.class, Test2.class}publicclass MySuite {}

 

 

Now IntelliJ complains that "@RunWith" expects a parameter of type Class[], but it found an element of type Class<?> instead. It's clear to me why this happens, because strictly speaking, @RunWith defines it's "value" to be a class array. However, it is allowed by the Java compiler (and customary for developers) to pass a single object when only one is needed in place of an array.

 

What I would need to do to satisfy IntelliJ IDEA in this case is:

 

@RunWith(new Class[]{PackageSuite.class}

 

... but that's definitly not what I want to do, it's too much syntactic noise and reduces readability while it doesn't provide any additional information.

 

In Eclipse, this works out-of-the-box. How do I tell IntelliJ that it should not give me errors or warnings in such a case?

 

 

Thanks,

 

 

Martin


Viewing all articles
Browse latest Browse all 5661

Trending Articles