Search code examples
javaintellij-ideasnakeyaml

Unable to run unit tests with Snakeyaml in IntelliJ


I have created a Java component which reads a YAML file using SnakeYaml. The environment I use is IntelliJ with a Maven plug-in and my project is built using a Maven pom file. When I run the Maven test project, my unit tests all pass. However, when I run the unit tests within IntelliJ directly, they fail.

Specifically, the call new Yaml(myConstructor) below is throwing an exception:

Constructor myConstructor = new Constructor(....)
Yaml yaml = new Yaml(myConstructor)

The specific exception is:

java.lang.NoSuchMethodError: org.yaml.snakeyaml.Yaml.(Lorg/yaml/snakeyaml/constructor/BaseConstructor;)V

Any ideas?


Solution

  • Take look at file -> proj structure -> artifacts. There can be error. Just click at "Fix" button. Also try recreate itellij project from maven configuration. Usually there is troubles with libraries scopes, like TEST/PROVIDED.