在我的项目中,我使用带有junit,maven和selenium webdriver的黄瓜,包括java和范围报告。 我的范围报告是在文件夹'输出'中生成的。并且在同一文件夹中也保存了失败的测试用例的屏幕截图。 执行测试并生成报告后,我想压缩文件夹'输出'到zip文件并邮寄。
问题:在我的代码将文件转换为zip格式的情况下,尚未生成测试报告(因为它在完成所有测试用例后生成),因此当输出'文件夹被压缩它只包含失败的屏幕截图,同样正在邮寄.. 请建议 this is my runner file this is my hooks class
@CucumberOptions(
features = {"featurefiles/DefineStaffType.feature"}
, glue = {"stepdefinitions"}
, monochrome = true
, plugin = {"pretty:STDOUT",
"json:target/cucumber.json",
"junit:target/cucumber.xml",
"com.cucumber.listener.ExtentCucumberFormatter:output/report.html"}
, tags = {"@Scenario1, @Scenario2, @Scenario3"}
)
public class DefineStaffTypeRunner {
@AfterClass
public static void reportSetup ( ) throws IOException, EmailException {
Reporter.loadXMLConfig ( new File ( "configuration\\extentconfig.xml" ) );
Reporter.setSystemInfo ( "User Name", System.getProperty ( "user.name" ) );
Reporter.setSystemInfo ( "Time Zone", System.getProperty ( "user.timezone" ) );
Reporter.setSystemInfo ( "64 Bit", "Windows 10" );
Reporter.setSystemInfo ( "3.1.0", "Selenium" );
Reporter.setSystemInfo ( "1.9", "Maven" );
Reporter.setSystemInfo ( "1.9", "Java Version" );
Reporter.setTestRunnerOutput ( "Define Staff Type " );
FileConversion.convertToZip ( "output" );
new MailHandlingUtility ( ).sendMailWithAttachment ( );
}
}
public class CucumberHooks extends GenericBaseClass {
DriverMethods dm = new DriverMethods ( );
CaptureScreenshot cs = new CaptureScreenshot ( );
static MailHandlingUtility mhu = new MailHandlingUtility ( );
@Before
public void launchBrowser (Scenario currentscenario) throws IOException {
this.scenario = currentscenario;
driver = getCurrentDriver ( );
dm.maximizeWindow ( );
}
@After
public void tearDownScenario (Scenario currentscenario) throws IOException, EmailException {
scenario.write ( "Scenario is finished" + currentscenario );
cs.catureScreenshot ( (Scenario) scenario );
driver.close ( );
driver.quit ( );
driver = null;
}
}