use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestTestLogging method testWarning.
@Test(groups = { "ut" })
public void testWarning() {
TestStepManager.setCurrentRootTestStep(new TestStep("step", null, new ArrayList<>(), true));
logger.warning("message");
Assert.assertEquals(((TestMessage) (TestStepManager.getParentTestStep().getStepActions().get(0))).getMessageType(), MessageType.WARNING);
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestTestLogging method testRelocateHar.
@Test(groups = { "ut" })
public void testRelocateHar() 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(SeleniumTestsContextManager.getThreadContext().getOutputDirectory() + "_moved");
File movedFile = Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory() + "_moved", "main-networkCapture.har").toFile();
Assert.assertTrue(movedFile.exists());
Assert.assertFalse(initialFile.exists());
Assert.assertEquals(TestStepManager.getParentTestStep().getHarCaptures().get(0).getFile(), 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 testRelocateScreenshotHtmlOnly.
/**
* Check HTML page is moved
* @throws IOException
*/
@Test(groups = { "ut" })
public void testRelocateScreenshotHtmlOnly() throws IOException {
try {
TestStepManager.setCurrentRootTestStep(new TestStep("step", null, new ArrayList<>(), true));
ScreenShot screenshot = new ScreenShot();
String htmlSourcePath = Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory(), ScreenshotUtil.HTML_DIR, "capture.html").toString();
FileUtils.write(new File(htmlSourcePath), "<html>");
// copied from ScreeshotUtils class
screenshot.setHtmlSourcePath(String.format("../%s/%s/%s.html", "testRelocateScreenshotHtmlOnly", ScreenshotUtil.HTML_DIR, "capture"));
logger.logScreenshot(screenshot);
File initialFile = new File(TestStepManager.getParentTestStep().getSnapshots().get(0).getScreenshot().getFullHtmlPath());
// file exists before moving
Assert.assertTrue(initialFile.exists());
Assert.assertNull(TestStepManager.getParentTestStep().getSnapshots().get(0).getScreenshot().getImagePath());
// relocate
TestStepManager.getParentTestStep().getSnapshots().get(0).relocate(SeleniumTestsContextManager.getThreadContext().getOutputDirectory() + "_moved");
File movedFile = Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory() + "_moved", ScreenshotUtil.HTML_DIR, "N-A_0-1_step--pture.html").toFile();
Assert.assertTrue(movedFile.exists());
Assert.assertFalse(initialFile.exists());
Assert.assertEquals(new File(TestStepManager.getParentTestStep().getSnapshots().get(0).getScreenshot().getFullHtmlPath()), 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 testLogHarOk.
@Test(groups = { "ut" })
public void testLogHarOk() {
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");
Assert.assertFalse(TestStepManager.getParentTestStep().getHarCaptures().isEmpty());
Assert.assertTrue(Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory(), "main-networkCapture.har").toFile().exists());
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestTestStep method testPasswordMaskingSubStep.
/**
* Check that if a substep adds password values, parent step is not impacted
*/
@Test(groups = { "ut" })
public void testPasswordMaskingSubStep() {
TestStep step = new TestStep("step1 with args: (bar, passwd)", null, new ArrayList<>(), true);
TestStep substep = new TestStep("substep with args: (passwd)", null, Arrays.asList("passwd"), true);
TestAction action = new TestAction("action in step1 with args: (foo, passwd)", false, new ArrayList<>());
TestMessage message = new TestMessage("everything OK on passwd", MessageType.INFO);
step.addAction(substep);
substep.addAction(action);
substep.addMessage(message);
Assert.assertEquals(step.getName(), "step1 with args: (bar, passwd)");
Assert.assertEquals(action.getName(), "action in step1 with args: (foo, ******)");
Assert.assertEquals(message.getName(), "everything OK on ******");
Assert.assertEquals(substep.getName(), "substep with args: (******)");
}
Aggregations