use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestTestLogging method testLogFileSamePlace.
/**
* Check no error is raised if file is already at the right place
* @throws IOException
*/
@Test(groups = { "ut" })
public void testLogFileSamePlace() throws IOException {
TestStepManager.setCurrentRootTestStep(new TestStep("step", null, new ArrayList<>(), true));
File videoFile = File.createTempFile("video", ".avi");
FileUtils.moveFile(videoFile, Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory(), videoFile.getName()).toFile());
logger.logFile(videoFile, "video");
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestTestLogging method testRelocateScreenshotImageOnly.
/**
* Check image file is moved
* @throws IOException
*/
@Test(groups = { "ut" })
public void testRelocateScreenshotImageOnly() 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(), "");
// relocate
TestStepManager.getParentTestStep().getSnapshots().get(0).relocate(SeleniumTestsContextManager.getThreadContext().getOutputDirectory() + "_moved");
File movedFile = Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory() + "_moved", ScreenshotUtil.SCREENSHOT_DIR, "N-A_0-1_step--apture.png").toFile();
Assert.assertTrue(movedFile.exists());
Assert.assertFalse(initialFile.exists());
Assert.assertEquals(new File(TestStepManager.getParentTestStep().getSnapshots().get(0).getScreenshot().getFullImagePath()), movedFile);
} finally {
FileUtils.deleteQuietly(new File(SeleniumTestsContextManager.getThreadContext().getOutputDirectory()));
FileUtils.deleteQuietly(new File(SeleniumTestsContextManager.getThreadContext().getOutputDirectory() + "_moved"));
}
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestTestLogging method testBuildHarLog.
@Test(groups = { "ut" })
public void testBuildHarLog() throws IOException {
TestStepManager.setCurrentRootTestStep(new TestStep("step", null, new ArrayList<>(), true));
Har har = new Har(new HarLog());
har.getLog().addPage(new HarPage("title", "a title"));
HarCapture capture = new HarCapture(har, "main");
Assert.assertEquals(capture.buildHarLog(), "Network capture 'main' browser: <a href='main-networkCapture.har'>HAR file</a>");
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestTestLogging method testLogFile.
// GenericFile
@Test(groups = { "ut" })
public void testLogFile() throws IOException {
TestStepManager.setCurrentRootTestStep(new TestStep("step", null, new ArrayList<>(), true));
File videoFile = File.createTempFile("video", ".avi");
videoFile.deleteOnExit();
logger.logFile(videoFile, "video");
// check file has been moved to log folder
Assert.assertTrue(Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory(), videoFile.getName()).toFile().exists());
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestTestLogging method testLog.
@Test(groups = { "ut" })
public void testLog() {
TestStepManager.setCurrentRootTestStep(new TestStep("step", null, new ArrayList<>(), true));
logger.log("message");
Assert.assertEquals(((TestMessage) (TestStepManager.getParentTestStep().getStepActions().get(0))).getMessageType(), MessageType.LOG);
}
Aggregations