I am trying to run my project through 'Maven test', but I am getting various errors related to apache poi. I right click on the project folder in Eclipse and run the test as 'Maven test', but it ends up in giving error.
Please find one of the example errors given below:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@e73f9ac
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@3224f60b
Tests run: 3, Failures: 1, Errors: 0, Skipped: 1, Time elapsed: 10.595 sec <<< FAILURE!
init(com.Shree_Automate_Feb2019.base.BaseTest) Time elapsed: 7.486 sec <<< FAILURE!
java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Font
at com.Shree_Automate_Feb2019.base.BaseTest.init(BaseTest.java:61)
Caused by: java.lang.ClassNotFoundException: org.apache.poi.ss.usermodel.Font
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 35 more
Results :
Failed tests: init(com.Shree_Automate_Feb2019.base.BaseTest): org/apache/poi/ss/usermodel/Font
Tests run: 3, Failures: 1, Errors: 0, Skipped: 1
Instructor
Ashish Thakur Replied on 30/05/2019
Please check BaseTest.java, line number 61 for the possible error.
I checked and do not see any issue as the tests run fine with testng.xml and directly the testcase.class files.
The issue is only with maven test while running the project folder. Please find the screenshot for your reference.
I think that Maven expects all the poi files to be latest and/or of same version. We are using your poi files for Xls_Reader which are not latest version and maybe that is causing the problem?
Instructor
Ashish Thakur Replied on 31/05/2019
Please use POI 3.6 everywhere.
Yes, I am already using that. As said, the same configuration is working fine at testng.xml and individual testcases level.
Instructor
Ashish Thakur Replied on 04/06/2019
Please share your project in a compressed zip file.
I am unable to attach the zip file sized 16mb. How to do it?
Instructor
Ashish Thakur Replied on 12/06/2019
share the screenshot for the error.
Alternatively, share the file in OneDrive or Google Drive
Please access the zip file at https://drive.google.com/open?id=1k-uw12KSJzU448uZllxpiO32pQq5xP9a.
Instructor
Ashish Thakur Replied on 25/07/2019
As I imported your code and found many issues with your project structure. I would suggest you watch the framework videos again and rebuild the framework accordingly.
I found issues with dependencies in POM.xml and when we're using maven, we need not to import jars manually.
You can close this for now. I will open separate specific ticket as needed.