TestNG. BeforeSuite is not executed

Using Gradle with Java and TestNG and having following problem - I have a class, which has BeforeSuite annotation, but it is not executed.

public class BaseUITest {

    @BeforeSuite(alwaysRun = true)
    public void setUp(){
public class TestLogin extends BaseUITest {

    public void correctLogin() {

In testng.xml I have following:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Suite">
    <test name="Regression">
            <class name="com.example.com.ui.tests.TestLogin"/>

And in build.gradle in module:

plugins {
    id 'java'

sourceCompatibility = '1.8'
targetCompatibility = '1.8'

repositories {

ext {
    testNgVersion = '6.14.3'

dependencies {
    testCompile "org.testng:testng: $testNgVersion"

test {
        suites 'src/test/resources/testng.xml'

And in main build.gradle:

buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2"

subprojects {
    apply plugin: 'java'

    repositories {

In console I see only “correctLogin”, but there is no “BaseUITest”.

If I remove line suites 'src/test/resources/testng.xml' from build.gradle in the module, test runs Ok, BeforeSuite is executed.

Tried to add groupByInstances = true and preserveOrder true in build.gradle file in the module - it doesn’t help.

Hey bro!

I was with the same issue, try this: https://stackoverflow.com/questions/44039365/testng-skipping-beforesuite-and-beforeclass-when-running-in-group

Use for before and after methods the tag alwaysRun. Like this: @AfterSuite (alwaysRun=true)

I hope that can save you, see ya!