I am using openCSV jar to work with csv present in my parser project, now I want to unit test my parser and for that I get call pass it to object of my parser class so that I can go ahead and do parsing.
Now am getting java.lang.NoClassDefFoundError: au/com/bytecode/opencsv/CSVReader, openCSV jar is already present in the project but now if i try to run unit test, i get above mentioned error.
How can i set project classpath in intellij idea so that I can run unit test having reference to all dependent jars.
Thoughts?
If you have different modules for your project and unit testing than you need to add dependency of that .jar also in your unit testing module.
For e.g. When I am making project using IntelliJ I create modules.
for e.g. I have two modules:
mainandtest. Than I create libraries for my main module and for my test module and add them into modules dependencies.I am using IntelliJ 10.5.4 so the path would be: File -> Project Structure -> Modules -> main -> Dependencies -> Add -> then I select created library.
Also you can add module dependencies to other modules and use their classes.
Hope this helps.