0

Can we use the Mockito framework in a simple Java project without maven and Gradle? I saw many youtube videos but all of them use either Maven or Gradle. I do not understand why they do not use it in a simple java project.

Fahin Miah
  • 19
  • 5
  • 1
    At a high level: download their jars, and then add them to your project's classpath (both at compile time and runtime). How you do the latter depends on what tools you're using: command line, an IDE, etc. The tools' documentation will have more specifics. – yshavit Apr 25 '22 at 14:22
  • Does this answer your question? [How do you use a Java Library?](https://stackoverflow.com/questions/825521/how-do-you-use-a-java-library) – Progman Apr 25 '22 at 18:02
  • You can, but using a build tool such as maven or gradle is a standard in the industry, and for good reason. Check 'build systems and build philosophy' in [Software Engineering at Google](https://abseil.io/resources/swe_at_google.2.pdf) for a primer. – Lesiak Apr 26 '22 at 09:32
  • Could you please tell me how to add Mockito dependency in a simple Java project without Maven and Gradle? there are many files in a Java project, in which file will I add those dependency? – Fahin Miah Apr 26 '22 at 21:34
  • The problem is there is no way to tell what you mean by 'simple java project'. I guess you are using sth defined by your IDE, or you have your own toolchain. – Lesiak Apr 27 '22 at 10:02
  • I mean by "simple Java project", In intellij IDEA, file>new>project>java. – Fahin Miah Apr 27 '22 at 11:34

1 Answers1

0

Can we use the Mockito framework in a simple Java project without maven and Gradle? I saw many youtube videos but all of them use either Maven or Gradle. I do not understand why they do not use it in a simple java project.

Yes. People do this every day as this. It's the 'normal' way to use Mockito.

Here is an example project that uses an older version of mockito, but the concept is still the same: https://java2blog.com/mockito-junit/

Jonathan S. Fisher
  • 8,189
  • 6
  • 46
  • 84