I have a Spring application where I am using EasyMock for mocking in JUnit tests.
I have three classes (let's say A and B and C) defined below.
@Named("A")
@Primary
public class A {
}
@Named("B")
public class B extends A {
}
public class C {
@Inject
private A a; // It should inject A instance here since it is marked as primary
}
public class CTest {
@Mock
private A a;// Here I'm getting exception
}
When I run tests in CTest class, I'm getting error expected single matching bean but found 2:(A and B).
Why @primary annotation is not working here.