-2

I'm at university and I have to submit a project. I'm having problems with Assertj and JUnit when importing. I'll leave below some images of my problem.

enter image description here

I'll really appreciate if someone could help me! Thank you!

Joaco Terniro
  • 115
  • 1
  • 2
  • 13

2 Answers2

1

I don't know why but sometimes not including scope will make it work.

<dependency>
    <groupId>org.assertj</groupId>
    <artifactId>assertj-core</artifactId>
    <version>3.22.0</version>
    <!--<scope>test</scope> --> <!-- I have commented this line out and it worked -->
</dependency> 
janw
  • 8,758
  • 11
  • 40
  • 62
ZackSalom
  • 31
  • 3
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 14 '22 at 17:26
0

You'll need to get both the junit and assertj jar files added to your class path. You can either do this within your IDE manually (Intellij includes the junit library, but you'll have to download assertj seperately and add them as dependencies as outlined here), or by using a build system that downloads dependencies from a central repository, like maven. You can then get intellij to use your pom.xml (maven build configuration), so everything can still be run from within your IDE.

A trivial pom might be something like the following:

<project>
  <groupId>com.mycompany</groupId>
  <artifactId>my-project</artifactId>
  <version>1.0</version>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <!-- use 3.1.0 for Java 8 projects -->
      <version>2.1.0</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>
Edd
  • 3,724
  • 3
  • 26
  • 33