Software Cats - Blog
Testing

Part 6— Java Autotests for a Site from Scratch. The Code. Connecting Libraries

Starting to write a code and connecting libraries in a POM file.

Let’s open our project in IDEA and review its structure.
Please check the pom.xml file (“POM” stands for Project Object Model). It’s a special XML file in the root folder of your project that contains information about the project, configuration details, libraries, and plugins used by Mavin to create a project.

First, let’s add some info on our project <groupId>package_name</groupId>

<artifactId>program_name</artifactId>

<version>program_version</version>

Now let’s connect some libraries.

Library is a complete solution that we can use to create our programs.

As a rule, most of the popular libraries are stored in the Maven central repository. There you can find the necessary library and learn how to connect it. By the way, Maven uses the word “dependencies” for libraries.
To add a new dependency, you need to create a new <dependencies></dependencies> block in your POM file.

This block will contain all dependencies, and every dependency should be declared within the <dependency></dependency> tag.

To write UI tests, we’ll need the JUnit, Selenium, and Selenide dependencies.
<dependencies>
   <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>4.13.2</version>
       <scope>test</scope>
   </dependency>
   <dependency>
       <groupId>org.seleniumhq.selenium</groupId>
       <artifactId>selenium-java</artifactId>
       <version>3.141.59</version>
   </dependency>
   <dependency>
       <groupId>com.codeborne</groupId>
       <artifactId>selenide</artifactId>
       <version>5.23.2</version>
   </dependency>
   </dependencies>
After adding the dependencies to the POM file in IDEA, you need to upload the changes to Maven. It is recommended to restart IDEA and Maven after adding the new libraries.