Basic MAVEN and JUnit Project

Ahmet BAYAR
2 min readJun 24, 2021

Maven is a java build and management tool. Maven helps us to create java projects too easily. Gradle and Ant are other tools which are java build and management tools in the market, but maven is the most popular tool. We can create our java project or test project with maven easily.

Let’s get started creating a maven project on Intellij İDE.

Step-1: Open Intellij IDE — -File — -NewProjet — -Maven

You should choose maven and click on the next button.

Step-2:Choose a name to your project and click on finish button

Step-3: Your project structure should be like that

Step-4: Most important thing in the maven project is the pom.xml file. We use the pom.xml file to add dependencies. We got the which needed dependencies from maven repositories In our project we use tree dependencies:

WebdriverManager

Selenium Java

JUnit.

Step-5: Our pom.xml file’s content like that

Step-6: Create a package under the src/test/java file which is named firstpackage and under the first package create a java file whose name is FirstClass.

Step-7: In our test we will use JUnit test annotation. JUnit test annotations are;

@Test

@Ignore: if you don’t want to run a test on our project, we can use this annotation.

@Before:run before each method

@After: run after each method

@BeforeClass:run before the Class

@AfterClass: run after the Class

Step-8:We are creating our first test project. In this project we want to go to three search pages which are google,bing and yandex.

Step-9: As you see we don’t use main method no longer ın our project

You can got all code from github repository

https://github.com/zoomokul/MavenandJunit.git

--

--