0
package com.edureka.testng1;

import org.testng.Reporter;
import org.testng.annotations.*;
public class AnnoitationsDemo {
    
    @BeforeSuite
    public void beforeSuiteMethod()
    {
        Reporter.log("Before suite Method",true);
    }
    
    @AfterSuite
    public void afterSuiteMethod()
    {
        Reporter.log("After suite method",true);
    }
    
    @BeforeClass
    public void beforeClassMethod()
    {
        Reporter.log("Before suite method",true);
    }
    
    @AfterClass
    public void afterClassMethod()
    {
        Reporter.log("After class method", true);
    }
    
    @BeforeMethod
    public void beforeMethod()
    {
        Reporter.log("Before method",true);
    }
    
    @AfterMethod
    public void afterMethod()
    {
        Reporter.log("After method",true);
    }
}
package com.edureka.testng1;

import org.testng.Reporter;
import org.testng.annotations.Test;

public class TaskModuleScripts {
    
    @Test (groups = {"Smoke", "Task"})
    public void task1()
    {
        Reporter.log("task 1 method");
    }
    
    @Test (groups = {"Smoke", "Task"})
    public void atask2()
    {
        Reporter.log("task 2 method");
    }
    
    @Test
    public void task3()
    {
        Reporter.log("task 3 method");
    }
    
    @Test
    public void task4()
    {
        Reporter.log("task 4 method");
    }
}

I am expecting the methods under @BeforeMethods should run before every test method. I have included the AnnoitationsDemo class under <Classes> tag of testng.xml

tripleee
  • 175,061
  • 34
  • 275
  • 318
  • Your `AnnoitationsDemo` (sic) class doesn't actually contain any tests. Add some and they'll run. – Jorn May 01 '23 at 13:37

0 Answers0