Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<p>x</p>

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 Pre-existing: spurious

x

property in pom.xml

Line 18 contains <p>x</p> inside the <properties> block. This defines a Maven property named p with value x. It's likely a leftover from debugging or testing. While it doesn't break the build, it's noise in the POM. This is pre-existing and unchanged by this PR.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed it's harmless leftover noise (defines an unused Maven property p=x) and, as you note, pre-existing and unchanged by this PR. Keeping this PR's diff scoped to the Java 21 / TestNG 7 / Selenium 4 upgrade, so I'm leaving it as-is here. Happy to remove it in a small follow-up cleanup if you'd like it gone.

</properties>

Expand All @@ -29,7 +29,7 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<version>7.10.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.relevantcodes/extentreports -->
Expand Down Expand Up @@ -62,7 +62,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<version>3.5.2</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>./src/test/resources/suites/testng.xml</suiteXmlFile>
Expand Down
51 changes: 51 additions & 0 deletions src/test/java/example/example/listeners/SuiteSummaryListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package example.example.listeners;

import org.testng.ISuite;
import org.testng.ISuiteListener;
import org.testng.ISuiteResult;
import org.testng.ITestContext;

import example.example.util.LoggerUtil;
import example.example.util.MailUtil;
import example.example.util.TestProperties;

/**
* Suite-level listener that loads global properties before the suite runs and,
* once the whole suite has finished, logs an execution summary and emails the
* report. This replaces the former {@code @BeforeSuite}/{@code @AfterSuite}
* hooks in {@code BaseTest}: TestNG 7 no longer supports native parameter
* injection into {@code @AfterSuite} methods, and a suite listener guarantees
* the summary runs exactly once per suite while aggregating results across every
* {@code <test>} tag.
*/
public class SuiteSummaryListener implements ISuiteListener {

@Override
public void onStart(ISuite suite) {
LoggerUtil.log("************************** Test Execution Started ************************************");
TestProperties.loadAllPropertie();
}
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.

@Override
public void onFinish(ISuite suite) {
int total = 0;
int passed = 0;
int failed = 0;
int skipped = 0;
for (ISuiteResult result : suite.getResults().values()) {
ITestContext context = result.getTestContext();
total += context.getAllTestMethods().length;
passed += context.getPassedTests().size();
failed += context.getFailedTests().size();
skipped += context.getSkippedTests().size();
}
LoggerUtil.log("Total number of testcases : " + total);
LoggerUtil.log("Number of testcases Passed : " + passed);
LoggerUtil.log("Number of testcases Failed : " + failed);
LoggerUtil.log("Number of testcases Skipped : " + skipped);
boolean mailSent = MailUtil.sendMail(total, passed, failed, skipped);
LoggerUtil.log("Mail sent : " + mailSent);
LoggerUtil.log("************************** Test Execution Finished ************************************");
}

}
39 changes: 2 additions & 37 deletions src/test/java/example/example/tests/BaseTest.java

@devin-ai-integration devin-ai-integration Bot Jun 17, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Pre-existing: driver.close() followed by driver.quit() can throw

The wrapUp() method calls driver.close() then driver.quit(). When there is only one browser window (the typical case here), close() closes the last window and may invalidate the session, causing quit() to throw a NoSuchSessionException. This is a pre-existing issue not introduced by this PR, but worth noting since the PR touches this class. The fix would be to just call driver.quit() (which closes all windows and ends the session).

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed this is pre-existing (wrapUp() is unchanged by this PR) and, as you note, not a regression. Since this PR's scope is strictly the Java 21 / TestNG 7 / Selenium 4 upgrade and the teardown isn't causing failures in the current suite, I'm intentionally leaving it as-is to keep the upgrade diff minimal. Happy to file a follow-up to simplify it to a single driver.quit() if you'd like.

Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
package example.example.tests;

import java.util.concurrent.TimeUnit;
import java.time.Duration;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.testng.ITestContext;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Listeners;

import example.example.context.WebDriverContext;
import example.example.listeners.LogListener;
import example.example.listeners.ReportListener;
import example.example.util.LoggerUtil;
import example.example.util.MailUtil;
import example.example.util.TestProperties;
import io.github.bonigarcia.wdm.WebDriverManager;

/**
Expand All @@ -31,35 +25,6 @@ public class BaseTest {
/** The driver. */
protected WebDriver driver;

/**
* Global setup.
*/
@BeforeSuite(alwaysRun = true)
public void globalSetup() {
LoggerUtil.log("************************** Test Execution Started ************************************");
TestProperties.loadAllPropertie();
}

/**
* Wrap all up.
*
* @param context the context
*/
@AfterSuite(alwaysRun = true)
public void wrapAllUp(ITestContext context) {
int total = context.getAllTestMethods().length;
int passed = context.getPassedTests().size();
int failed = context.getFailedTests().size();
int skipped = context.getSkippedTests().size();
LoggerUtil.log("Total number of testcases : " + total);
LoggerUtil.log("Number of testcases Passed : " + passed);
LoggerUtil.log("Number of testcases Failed : " + failed);
LoggerUtil.log("Number of testcases Skipped : " + skipped);
boolean mailSent = MailUtil.sendMail(total, passed, failed, skipped);
LoggerUtil.log("Mail sent : " + mailSent);
LoggerUtil.log("************************** Test Execution Finished ************************************");
}

/**
* Setup.
*/
Expand All @@ -74,7 +39,7 @@ protected void setup() {
ops.addArguments("--disable-dev-shm-usage");
driver = new ChromeDriver(ops);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
WebDriverContext.setDriver(driver);
}

Expand Down
4 changes: 3 additions & 1 deletion src/test/resources/suites/testng.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
<listeners></listeners>
<listeners>
<listener class-name="example.example.listeners.SuiteSummaryListener" />
</listeners>
<test thread-count="5" name="Test" parallel="classes">
<classes>
<class name="example.example.tests.GoogleSearchTest" />
Expand Down