Search in sources :

Example 16 with Uft

use of com.seleniumtests.connectors.extools.Uft in project seleniumRobot by bhecquet.

the class TestUft method testReadBadReport.

/**
 * Check that with wrong formatted report, the main test step is still present
 * but without content
 */
@Test(groups = { "ut" })
public void testReadBadReport() throws IOException {
    String report = GenericTest.readResourceToString("tu/wrongUftReport.xml");
    Uft uft = new Uft("[QualityCenter]Subject\\Tools\\Tests\\test1");
    List<TestStep> testSteps = uft.readXmlResult(report);
    Assert.assertEquals(testSteps.get(0).getStepActions().size(), 1);
    Assert.assertEquals(((TestMessage) testSteps.get(0).getStepActions().get(0)).getMessageType(), MessageType.ERROR);
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) Uft(com.seleniumtests.connectors.extools.Uft) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) GenericTest(com.seleniumtests.GenericTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 17 with Uft

use of com.seleniumtests.connectors.extools.Uft in project seleniumRobot by bhecquet.

the class TestUft method testPrepareArgumentsWithAlmTestAndParam.

@Test(groups = { "ut" })
public void testPrepareArgumentsWithAlmTestAndParam() {
    Map<String, String> params = new HashMap<>();
    params.put("User", "toto");
    Uft uft = new Uft("http://almserver/qcbin", "usr", "pwd", "dom", "proj", "[QualityCenter]Subject\\Tools\\Tests\\test1");
    uft.setParameters(params);
    List<String> args = uft.prepareArguments(true, true);
    Assert.assertEquals(args.size(), 11);
    Assert.assertTrue(args.get(0).startsWith(System.getProperty("java.io.tmpdir")));
    Assert.assertTrue(args.get(0).endsWith("uft.vbs"));
    Assert.assertTrue(args.get(1).equals("[QualityCenter]Subject\\Tools\\Tests\\test1"));
    Assert.assertTrue(args.get(2).equals("/execute"));
    Assert.assertTrue(args.get(3).equals("\"User=toto\""));
    Assert.assertTrue(args.get(4).equals("/server:http://almserver/qcbin"));
    Assert.assertTrue(args.get(5).equals("/user:usr"));
    Assert.assertTrue(args.get(6).equals("/password:pwd"));
    Assert.assertTrue(args.get(7).equals("/domain:dom"));
    Assert.assertTrue(args.get(8).equals("/project:proj"));
    Assert.assertTrue(args.get(9).equals("/load"));
    Assert.assertTrue(args.get(10).equals("/clean"));
    Assert.assertTrue(uft.isKillUftOnStartup());
}
Also used : Uft(com.seleniumtests.connectors.extools.Uft) HashMap(java.util.HashMap) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) GenericTest(com.seleniumtests.GenericTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 18 with Uft

use of com.seleniumtests.connectors.extools.Uft in project seleniumRobot by bhecquet.

the class TestUft method testExecute.

@Test(groups = { "ut" })
public void testExecute() throws Exception {
    String report = GenericTest.readResourceToString("tu/uftReport.xml");
    report = "some comments\n_____OUTPUT_____\n" + report + "\n_____ENDOUTPUT_____\nsome other comments";
    PowerMockito.when(TestTasks.class, "executeCommand", eq("cscript.exe"), anyInt(), nullable(Charset.class), any()).thenReturn(report);
    Map<String, String> args = new HashMap<>();
    args.put("User", "toto");
    Uft uft = new Uft("[QualityCenter]Subject\\OUTILLAGE\\Tests_BHE\\test1");
    uft.loadScript(false);
    List<TestStep> testSteps = uft.executeScript(120, args);
    // check a step is returned
    Assert.assertNotNull(testSteps);
    ArgumentCaptor<String[]> argsArgument = ArgumentCaptor.forClass(String[].class);
    PowerMockito.verifyStatic(TestTasks.class);
    TestTasks.executeCommand(eq("cscript.exe"), eq(120), isNull(), argsArgument.capture());
    Assert.assertEquals(argsArgument.getAllValues().size(), 4);
    Assert.assertEquals(argsArgument.getAllValues().get(1), "[QualityCenter]Subject\\OUTILLAGE\\Tests_BHE\\test1");
    Assert.assertEquals(argsArgument.getAllValues().get(2), "/execute");
    Assert.assertEquals(argsArgument.getAllValues().get(3), "\"User=toto\"");
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) Uft(com.seleniumtests.connectors.extools.Uft) HashMap(java.util.HashMap) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) TestTasks(com.seleniumtests.core.TestTasks) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) GenericTest(com.seleniumtests.GenericTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 19 with Uft

use of com.seleniumtests.connectors.extools.Uft in project seleniumRobot by bhecquet.

the class TestUft method testPrepareLoadArgumentsWithAlmTestMissingServerValues.

/**
 * If some ALM values are missing, throw a configuration exception
 */
@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class)
public void testPrepareLoadArgumentsWithAlmTestMissingServerValues() {
    Uft uft = new Uft(null, "usr", "pwd", "dom", "proj", "[QualityCenter]Subject\\Tools\\Tests\\test1");
    uft.setKillUftOnStartup(false);
    uft.prepareArguments(true, false);
}
Also used : Uft(com.seleniumtests.connectors.extools.Uft) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) GenericTest(com.seleniumtests.GenericTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 20 with Uft

use of com.seleniumtests.connectors.extools.Uft in project seleniumRobot by bhecquet.

the class TestUft method testExecuteNothingReturned.

@Test(groups = { "ut" })
public void testExecuteNothingReturned() throws Exception {
    String report = "";
    PowerMockito.when(TestTasks.class, "executeCommand", eq("cscript.exe"), anyInt(), nullable(Charset.class), any()).thenReturn(report);
    Map<String, String> args = new HashMap<>();
    args.put("User", "toto");
    Uft uft = new Uft("[QualityCenter]Subject\\OUTILLAGE\\Tests_BHE\\test1");
    uft.loadScript(false);
    List<TestStep> testSteps = uft.executeScript(5, args);
    // check a step is returned
    Assert.assertFalse(testSteps.isEmpty());
    Assert.assertEquals(testSteps.get(0).getName(), "UFT: test1");
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) Uft(com.seleniumtests.connectors.extools.Uft) HashMap(java.util.HashMap) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) TestTasks(com.seleniumtests.core.TestTasks) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) GenericTest(com.seleniumtests.GenericTest) MockitoTest(com.seleniumtests.MockitoTest)

Aggregations

Uft (com.seleniumtests.connectors.extools.Uft)27 MockitoTest (com.seleniumtests.MockitoTest)26 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)26 Test (org.testng.annotations.Test)26 GenericTest (com.seleniumtests.GenericTest)25 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)20 TestStep (com.seleniumtests.reporter.logger.TestStep)8 TestTasks (com.seleniumtests.core.TestTasks)7 HashMap (java.util.HashMap)7 SeleniumRobotTestPlan (com.seleniumtests.core.runner.SeleniumRobotTestPlan)1