use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestTestLogging method testError.
@Test(groups = { "ut" })
public void testError() {
TestStepManager.setCurrentRootTestStep(new TestStep("step", null, new ArrayList<>(), true));
logger.error("message");
Assert.assertEquals(((TestMessage) (TestStepManager.getParentTestStep().getStepActions().get(0))).getMessageType(), MessageType.ERROR);
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestTestLogging method testLogScreenshotOk.
@Test(groups = { "ut" })
public void testLogScreenshotOk() {
TestStepManager.setCurrentRootTestStep(new TestStep("step", null, new ArrayList<>(), true));
logger.logScreenshot(new ScreenShot());
Assert.assertEquals(TestStepManager.getParentTestStep().getSnapshots().size(), 1);
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestTestLogging method testRelocateHarNull.
/**
* Test no error is raised is outputDirectory is null
* @throws IOException
*/
@Test(groups = { "ut" })
public void testRelocateHarNull() throws IOException {
try {
TestStepManager.setCurrentRootTestStep(new TestStep("step", null, new ArrayList<>(), true));
Har har = new Har(new HarLog());
har.getLog().addPage(new HarPage("title", "a title"));
logger.logNetworkCapture(har, "main");
File initialFile = TestStepManager.getParentTestStep().getHarCaptures().get(0).getFile();
// file exists before moving
Assert.assertTrue(initialFile.exists());
// relocate
TestStepManager.getParentTestStep().getHarCaptures().get(0).relocate(null);
} finally {
FileUtils.deleteQuietly(new File(SeleniumTestsContextManager.getThreadContext().getOutputDirectory()));
}
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestTestLogging method testInfo.
@Test(groups = { "ut" })
public void testInfo() {
TestStepManager.setCurrentRootTestStep(new TestStep("step", null, new ArrayList<>(), true));
logger.info("message");
Assert.assertEquals(TestStepManager.getParentTestStep().getStepActions().size(), 1);
Assert.assertTrue(TestStepManager.getParentTestStep().getStepActions().get(0) instanceof TestMessage);
Assert.assertEquals(((TestMessage) (TestStepManager.getParentTestStep().getStepActions().get(0))).getMessageType(), MessageType.INFO);
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestTestLogging method testRelocateScreenshotSamePath.
@Test(groups = { "ut" })
public void testRelocateScreenshotSamePath() throws IOException {
try {
TestStepManager.setCurrentRootTestStep(new TestStep("step", null, new ArrayList<>(), true));
ScreenShot screenshot = new ScreenShot();
String imgSourcePath = Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory(), ScreenshotUtil.SCREENSHOT_DIR, "capture.png").toString();
FileUtils.write(new File(imgSourcePath), "<img>");
// copied from ScreeshotUtils class
screenshot.setImagePath(String.format("%s/%s.png", ScreenshotUtil.SCREENSHOT_DIR, "capture"));
logger.logScreenshot(screenshot);
File initialFile = new File(TestStepManager.getParentTestStep().getSnapshots().get(0).getScreenshot().getFullImagePath());
// file exists before moving
Assert.assertTrue(initialFile.exists());
Assert.assertEquals(TestStepManager.getParentTestStep().getSnapshots().get(0).getScreenshot().getHtmlSource(), "");
// check no error is raised if we ask the files to be moved at the same place
TestStepManager.getParentTestStep().getSnapshots().get(0).relocate(SeleniumTestsContextManager.getThreadContext().getOutputDirectory());
} finally {
FileUtils.deleteQuietly(new File(SeleniumTestsContextManager.getThreadContext().getOutputDirectory()));
FileUtils.deleteQuietly(new File(SeleniumTestsContextManager.getThreadContext().getOutputDirectory() + "_moved"));
}
}
Aggregations