I'm trying this guide to learn to integrate Maven, Jenkins and Selenium. The issue with guides is the erosion of time and serious compatibility issues. I've been trying to debug it as I go, but right now I'm at step 15 and can't go further due to this issue:
T E S T S ------------------------------------------------------- Running example.NewTest Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 2.255 sec <<< FAILURE!
Results :
Failed tests: example.NewTest.testEasy(): org/testng/AssertJUnit
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 9.145s [INFO] Finished at: Tue Sep 12 09:42:36 PDT 2017 [INFO] Final Memory: 7M/17M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project WDTest: There are test failures. [ERROR] [ERROR] Please refer to C:\ST\kpimuiws-build-changes\WDTest\target\surefire-reports for the individual test results.
The surefire reports textfile shows:
Test set: example.NewTest
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 2.255 sec <<< FAILURE! example.NewTest.testEasy() Time elapsed: 2.25 sec
<<< FAILURE! java.lang.NoClassDefFoundError: org/testng/AssertJUnit at example.NewTest.testEasy(NewTest.java:34) Caused by: java.lang.ClassNotFoundException: org.testng.AssertJUnit
at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 19 more
Here is my pom;
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>WDTest</groupId>
<artifactId>WDTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<inherited>true</inherited>
<configuration>
<suiteXmlFile>testng.xml</suiteXmlFile>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.45.0</version>
</dependency>
</dependencies>
</project>
and here is my NewTest.java
package example;
import java.io.File;
import org.testng.annotations.Test;
//import org.testng.Assert;
import org.testng.AssertJUnit;
//import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxBinary;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
//import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
public class NewTest {
//private WebDriver driver;
File pathBinary = new File("C:\\Users\\T667627\\AppData\\Local\\MozillaFirefox\\firefox.exe");
FirefoxBinary firefoxBinary = new FirefoxBinary(pathBinary);
FirefoxProfile firefoxProfile = new FirefoxProfile();
WebDriver driver = new FirefoxDriver(firefoxBinary, firefoxProfile);
@Test
public void testEasy() {
driver.get("http://demo.guru99.com/selenium/guru99home/");
String title = driver.getTitle();
AssertJUnit.assertTrue(title.contains("Demo Guru99 Page"));
}
@BeforeTest
public void beforeTest() {
driver = new FirefoxDriver();
}
@AfterTest
public void afterTest() {
driver.quit();
}
}