"java.lang.NoSuchFieldError: FACTORY" while running Junit test in AEM codebase
I was implementing Unit testing for a already running AEM project. After adding all the dependencies and after creation of basic structure for Sling model test class my test gets executed as expected. @ ExtendWith ({ AemContextExtension . class , MockitoExtension . class }) class DummyComponentImplTest { @ BeforeEach void setUp () { } @ Test public void testGetHeading () { } } But soon as I add below line at line #25 in the above running test case private final AemContext aemContext = new AemContext (); and try to run the test in terminal getting below error in the terminal's maven console. Running com . myproject . aem . models . impl . DummyComponentImplTest [ERROR] Tests run : 1 , Failures : 0 , Errors : 1 , Skipped : 0 , Time elapsed : 2.258 s <<< FAILURE! - in com . myproject . aem . models . impl . DummyComponentImplTest [ERROR] testGetHeading Time elapsed : 0.007 s <<< ERROR! java . lang . NoSuchFieldError...