"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.
But soon as I add below line at line #25 in the above running test case
and try to run the test in terminal getting below error in the terminal's maven console.
after doing so much google did some changes at the dependency level based on the solutions, from google search, but things didn't changed for me.
Problem was very simple but as I was not getting much stack trace either in console or in surefire-report.txt file, not able to identify the actual cause for the problem.
When I run the same test case in eclipse, same error but the good thing was the stack trace for the error.
Here I got to know the name and the location of the existing Sling model. In the particular sling model there were an unused Gson object in class scope, which was the culprit.
So I had only few options like either remove the private static modifier for the object or remove this entire line since the Gson object was unused so I commented it out and finally got my easy test ride 😄
Thank you.
Comments
Post a Comment