Saturday, December 13, 2014

Integrating Maven and TestNG with Eclipse

OK, this a pretty simple article, but I decided to publish this first as a requisite to integrate Java + Selenium + Maven + testNG + ReportNG. I don't want that to be a extremely long text, so this short article will help to reduce it. Just in case, I'm using a Ubuntu 14.04 machine, but the instructions are valid for Windows as well, as long as they are not commands in the terminal. Let's get started!

Requisites:

  • Eclipse (the latest version, download it here. I used Eclipse Luna, which includes Maven support)
  • Maven installed (instructions below)

Steps:

Installing Maven

1. Open a terminal
2. Enter the following classic command:

sudo apt-get install maven

3. Once the required files are downloaded and installed, type this in the console: mvn
If you see something like this:
Congratulations! Now you have Maven installed on your computer. However, you'll see an error message like this:

That means that you don't have your JAVA_HOME environment variable set. To do that in Ubuntu 14.04, open a terminal and enter the following command:

sudo gedit ~/.bashrc

Note: Gedit is a text editor, very useful. If you don't have it yet, install it with: sudo apt-get install gedit

A text editor will be opened. Go to the bottom of the text and enter the following lines:

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre
export PATH=$PATH:/usr/lib/jvm/java-7-openjdk-amd64/jre

Of course, you need to set the path where you have Java installed. Now, save the file and type this in the console:

source ~/.bashrc

Try the command mvn again. It should be working now.

Installing Eclipse and testNG

1. Once you download the compressed Eclipse file, just extract it somewhere. Once you do that, double click the "eclipse" icon:
Eclipse will open.
2. Go to Help > Eclipse Marketplace...
3. In the 'Find' field enter testng and click 'Go'.
4. Click 'Install' in 'TestNG for Eclipse'
5. Click 'Confirm'
6. Select 'I accept the terms of the licence agreement' and click 'Finish'
7. Click 'OK' in the Security Warning dialog.

8. Restart Eclipse and that's it, you now have testNG integrated with Eclipse.

With that, you'll be ready for the next article.

0 comentarios:

Post a Comment