Spring with 14.1.4 Could not Autowire Test

Someting happened when I recently upgraded from 14 to 14.1.4.

I have a base unit test class that is defined like this:

 
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(
    classes = {
        WorkerTestConfiguration.class,
        
DatabaseTestConfiguration.class,
        
MockMailConfiguration.class,
        
LayerTestConfiguration.class}
)
@ActiveProfiles("test")
public abstract class AbstractWorkerTest extends Test { ... }


If I have any @Inject statements in the above class they look fine in intellij. However, any tests that inherit from this class that have @Inject statements are highlighted as errors with the message "Could not autowire". The tests run fine, I just would like to get rid of this error WITHOUT disabling the inspection.

Also note that this error does not show up in any of my production classes in this package, only the tests classes that inherit from AbstractWorkerTest.

Any ideas? This was not previously the case.

R.

2 comments
Comment actions Permalink

Alright, I figured this out. Apparently previous version of IntelliJ inherited the @ComponentScan annotation differently. In my test package I have a TestAppConfiguration class that inherits from an AppConfiguration class. The AppConfiguration class includes the @ComponentScan annotation. This worked before. With the latest version I have to make sure that TestAppConfiguration (that extends AppConfiguration) also has the @ComponentScan annotation.

Any ideas what might have changed?

0
Comment actions Permalink

Could you please file a bug and attach the sample code if possible? Thanks.

https://youtrack.jetbrains.com/issues/IDEA

0

Please sign in to leave a comment.