'Maven test or mvn clean install test doesn't work. It shows only 'Build Success'
I'm stuck in this problem. I'm trying to test this project with maven. I typed 'mvn test', 'mvn test-compile', 'mvn package' and so on.Also try to Clean the project too many times reinstall maven/intellij and testng also try to change the testng.xml directory. But it always shows same output like this:
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< {{ProjectName}}:Automation >--------------------------
[INFO] Building {{ProjectName}}Automation 0.0.1-SNAPSHOT
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.113 s
[INFO] Finished at: 2022-03-16T17:30:56+02:00
[INFO] ------------------------------------------------------------------------
My POM is:
<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>SomeGroup</groupId>
<artifactId>Automation</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<includes>
<include>**/Test*.java</include>
<include>**/*Test.java</include>
<include>**/*TestCase.java</include>
</includes>
<suiteXmlFiles>
<suiteFile>src/tests/resources/suites/testng.xml</suiteFile>
</suiteXmlFiles>
<testFailureIgnore>true</testFailureIgnore>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
</plugins>
</build>
<packaging>pom</packaging>
<name>SomeName</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<suiteXmlFile>src/tests/resources/suites/testng.xml</suiteXmlFile>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>4.5.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>com.amihaiemil.web</groupId>
<artifactId>eo-yaml</artifactId>
<version>6.0.1</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.30</version>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>4.4.3</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports-testng-adapter</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.41.2</version>
</dependency>
<dependency>
<groupId>org.jboss.aerogear</groupId>
<artifactId>aerogear-otp-java</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>5.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts-core</artifactId>
<version>1.3.8</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>23.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>20041127.091804</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.21.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
My testng.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Web Automation">
<!-- <parameter name="env" value="${env}"/>-->
<!-- <parameter name="browser" value="${browser}" />-->
<parameter name="env" value="test"/>
<parameter name="browser" value="chrome"/>
<test name="patientTests" >
<packages>
<package name="FunctionalTests"/>
</packages>
</test>
</suite>
And structure is:
I would be glad if someone help me.. Everything starts with "classpath error" and things gone wrong
My TestCases looks like this:
package FunctionalTests;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.io.IOException;
public class LoginTest extends BaseTest{
@Test(groups = {"fullRegression","LoginTests", "PERRY-269", "sanityCheck"},
description = "Login as Provider with valid email")
public void loginAsProviderWithEmail() throws IOException {
logINFO("Enter email and password and click login.");
loginPage.loginWithEmail(providerEmail, providerPassword);
Assert.assertTrue(checkHttpResponseCode());
logINFO("Check if home page loaded (Top bar tracker button exists).");
Assert.assertTrue(providerHomePage.isPageLoaded(), "Home page not loaded.");
}
And my BaseTest looks like this:
@Listeners(Utils.Listeners.TestListener.class)
public class BaseTest {
LoginPage loginPage;
private static final String envYamlFilePath = "src/tests/resources/config/env.yml";
// public YamlReader environmentsYamlReader;
public static YamlReader environmentsYamlReader = new YamlReader(envYamlFilePath);
static final SoftAssert softAssert = new SoftAssert();
private static String providerEmailPath;
private static String providerPasswordPath;
private static String envPath;
static String providerEmail;
static String providerPassword;
static String url;
public RemoteWebDriver driver;
public WebDriverController instance;
public String WEBDRIVER = "driver";
@BeforeSuite
public void setUpSuite(ITestContext context) {
String browser = context.getCurrentXmlTest().getParameter("browser");
String env = context.getCurrentXmlTest().getParameter("env");
if (browser == null) browser = defaultBrowser;
if (env == null) env = defaultEnvironment;
envPath = env + ".url";
providerEmailPath = env + ".providerEmail";
providerPasswordPath = env + ".providerPassword";
url = environmentsYamlReader.read(envPath).get().toString();
providerEmail = environmentsYamlReader.read(providerEmailPath).get().toString();
providerPassword = environmentsYamlReader.read(providerPasswordPath).get().toString();
@BeforeMethod
public void setUpMethod(ITestContext context, ITestResult testResult) {
String browser = context.getCurrentXmlTest().getParameter("browser");
String env = context.getCurrentXmlTest().getParameter("env");
instance = new WebDriverController();
if (browser == null) browser = defaultBrowser;
if (env == null) env = defaultEnvironment;
driver = (RemoteWebDriver)instance.start(browser);
testResult.setAttribute(WEBDRIVER, driver);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));
driver.get(url);
loginPage = new LoginPage(driver);
}
@AfterMethod
public void cleanupBrowser(ITestResult testResult) {
RemoteWebDriver driver = driver(testResult);
driver.quit();
}
Solution 1:[1]
POM and testng.xml are just settings files.
You must have a test method with Test annotation. Also, some code running and finally a basic assert code.
[Test]
public void Test1() {
// Test code goes here
Assert.true(boolVal, "Testing that boolVal is true");
}
Make sure that your code creates test suite with actual test steps and cases.
Solution 2:[2]
Problem is resolved. The problem was that test folder was named 'tests' and this causes issues.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tal Angel |
| Solution 2 | Anton Kolev |
