Home > Software design >  TestNG Report is sending previous report
TestNG Report is sending previous report

Time:11-12

I have used this very simple code, and I have tried to send emailable report under the @AfterSuite Annotion but the problem is it is sending the old (previous) report. Not the latest one. Note I have also tried thread.sleep under the email method.

  package testOWC;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.AfterTest;
import org.testng.annotations.Test;
import java.io.IOException;

import javax.mail.MessagingException;

import java.awt.AWTException;

public class All_TestCases {
  
@SuppressWarnings({ })
@Test (priority =1)
public void RequiredFieldsOnly() throws InterruptedException, IOException, AWTException {
  RequiredFieldsOnly.testCase();
}
  
@Test (priority =2)
public void Yourself() throws InterruptedException, IOException, AWTException {
  Yourself.testCase();
  
}

@Test (priority =3)
public void Yourself_Representative() throws InterruptedException, IOException, AWTException {
  Yourself_Representative.testCase();
  
}

@Test (priority =4)
public void Representative_YourselfNotConf() throws InterruptedException, IOException, AWTException {
  Representative_YourselfNotConf.testCase();
  
}

@Test (priority =5)
public void Representative_YourselfConf() throws InterruptedException, IOException, AWTException {
  Representative_YourselfConf.testCase();
  
} 

@AfterSuite
public void email() throws MessagingException, InterruptedException {
  
  Email_Invoke.main(null);
}

 




}

CodePudding user response:

I think you are looking for a report in the wrong place. When you are running your tests with maven the report is generated in the target folder. When you are running with the testng.xml file the report is generated in the test-output folder. So I think after a run you are looking in the wrong place. Check it, please.

CodePudding user response:

Report will be generated after the completion of all Hooks.

  • @BeforeSuite
  • @BeforeTest
  • @BeforeClass
  • @BeforeMethod
  • @Test
  • @AfterMethod
  • @AfterClass
  • @AfterTest
  • @AfterSuite

Please write seperate program to send mail.

Approach :

  1. Create .bat file
  2. first command should be TestNG execution
  3. Second command should be your mail program

Sample bat file :

mvn test && java -jar zippingAndEmail.jar

  • Related