use of com.seleniumtests.reporter.logger.TestAction in project seleniumRobot by bhecquet.
the class TestTestStep method testGetFailedWithActionKo.
/**
* Checks getStepStatus correctly compute test step status if action is failed
* Step is OK
*/
@Test(groups = { "ut" })
public void testGetFailedWithActionKo() {
TestStep step = new TestStep("step1", null, new ArrayList<>(), true);
step.addAction(new TestAction("action1", false, new ArrayList<>()));
step.addAction(new TestAction("action2", true, new ArrayList<>()));
Assert.assertFalse(step.getFailed());
Assert.assertEquals(step.getStepStatus(), StepStatus.WARNING);
}
use of com.seleniumtests.reporter.logger.TestAction in project seleniumRobot by bhecquet.
the class TestTestStep method testListAllAttachments.
/**
* Check we get all files from a step and its sub steps
*
* @throws IOException
*/
@Test(groups = { "ut" })
public void testListAllAttachments() throws IOException {
TestStep step = new TestStep("step1", null, new ArrayList<>(), true);
// create screenshot for main step
ScreenShot screenshot1 = new ScreenShot();
File tmpImgFile = File.createTempFile("img", ".png");
File tmpImgFile2 = Paths.get(tmpImgFile.getParent(), "screenshots", tmpImgFile.getName()).toFile();
FileUtils.moveFile(tmpImgFile, tmpImgFile2);
File tmpHtmlFile = File.createTempFile("html", ".html");
File tmpHtmlFile2 = Paths.get(tmpHtmlFile.getParent(), "htmls", tmpHtmlFile.getName()).toFile();
FileUtils.moveFile(tmpHtmlFile, tmpHtmlFile2);
tmpImgFile.deleteOnExit();
tmpHtmlFile.deleteOnExit();
screenshot1.setOutputDirectory(tmpImgFile.getParent());
screenshot1.setLocation("http://mysite.com");
screenshot1.setTitle("mysite");
screenshot1.setImagePath("screenshots/" + tmpImgFile2.getName());
screenshot1.setHtmlSourcePath("htmls/" + tmpHtmlFile2.getName());
step.addSnapshot(new Snapshot(screenshot1, "main", SnapshotCheckType.FALSE), 0, null);
TestStep subStep = new TestStep("subStep", null, new ArrayList<>(), true);
// create screenshot for sub step
ScreenShot screenshot2 = new ScreenShot();
File tmpImgFile3 = File.createTempFile("img", ".png");
File tmpImgFile4 = Paths.get(tmpImgFile3.getParent(), "screenshots", tmpImgFile3.getName()).toFile();
FileUtils.moveFile(tmpImgFile3, tmpImgFile4);
screenshot2.setOutputDirectory(tmpImgFile3.getParent());
screenshot2.setLocation("http://mysite.com");
screenshot2.setTitle("mysite");
screenshot2.setImagePath("screenshots/" + tmpImgFile4.getName());
subStep.addSnapshot(new Snapshot(screenshot2, "main", SnapshotCheckType.TRUE), 0, null);
subStep.addAction(new TestAction("action1", true, new ArrayList<>()));
step.addAction(new TestAction("action2", false, new ArrayList<>()));
step.addAction(subStep);
List<File> attachments = step.getAllAttachments();
Assert.assertEquals(attachments.size(), 3);
Assert.assertEquals(attachments.get(0).getName(), "N-A_0-1_step1--" + tmpHtmlFile2.getName().substring(tmpHtmlFile2.getName().length() - 10));
Assert.assertEquals(attachments.get(1).getName(), "N-A_0-1_step1--" + tmpImgFile2.getName().substring(tmpImgFile2.getName().length() - 10));
Assert.assertEquals(attachments.get(2).getName(), "N-A_0-1_subStep--" + tmpImgFile4.getName().substring(tmpImgFile4.getName().length() - 10));
}
use of com.seleniumtests.reporter.logger.TestAction in project seleniumRobot by bhecquet.
the class TestTestStep method testPasswordMaskingHtmlEncodedMainStepWithSpecialCharacters.
/**
* issue #431: check encoded steps have there password encoded when using special characters
*/
@Test(groups = { "ut" })
public void testPasswordMaskingHtmlEncodedMainStepWithSpecialCharacters() {
TestStep step = new TestStep("step1 with args: (bar, 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);
TestStep substep = new TestStep("substep with args: (passwd§~$µ)", null, new ArrayList<>(), true);
step.addAction(action);
step.addMessage(message);
step.addStep(substep);
Assert.assertEquals(step.encode("html").getName(), "step1 with args: (bar, ******)");
Assert.assertEquals(action.encode("html").getName(), "action in step1 with args: (foo, ******)");
Assert.assertEquals(message.encode("html").getName(), "everything OK on ******");
Assert.assertEquals(substep.encode("html").getName(), "substep with args: (******)");
Assert.assertEquals(step.encode("html").toString(), "Step step1 with args: (bar, ******)\n" + " - action in step1 with args: (foo, ******)\n" + " - everything OK on ******\n" + " - Step substep with args: (******)");
}
use of com.seleniumtests.reporter.logger.TestAction in project seleniumRobot by bhecquet.
the class TestTestStep method testNoPasswordMasking.
/**
* check that when disabled, password masking does not change test step
*/
@Test(groups = { "ut" })
public void testNoPasswordMasking() {
TestStep step = new TestStep("step1 with args: (bar, passwd)", null, new ArrayList<>(), false);
TestStep substep = new TestStep("substep with args: (passwd)", null, Arrays.asList("passwd"), false);
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, passwd)");
Assert.assertEquals(message.getName(), "everything OK on passwd");
Assert.assertEquals(substep.getName(), "substep with args: (passwd)");
}
use of com.seleniumtests.reporter.logger.TestAction in project seleniumRobot by bhecquet.
the class TestTestStep method testGetFailedWithStepKo.
/**
* Checks getStepStatus correctly compute test step status if action is not
* failed but test step is KO
*/
@Test(groups = { "ut" })
public void testGetFailedWithStepKo() {
TestStep step = new TestStep("step1", null, new ArrayList<>(), true);
step.setFailed(true);
step.addAction(new TestAction("action1", false, new ArrayList<>()));
step.addAction(new TestAction("action2", false, new ArrayList<>()));
Assert.assertTrue(step.getFailed());
Assert.assertEquals(step.getStepStatus(), StepStatus.FAILED);
}
Aggregations