Search in sources :

Example 21 with Uft

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

the class TestUft method testPrepareLoadArgumentsWithAlmTest.

/**
 * Check we add ALM parameters if they are set on loading
 */
@Test(groups = { "ut" })
public void testPrepareLoadArgumentsWithAlmTest() {
    Uft uft = new Uft("http://almserver/qcbin", "usr", "pwd", "dom", "proj", "[QualityCenter]Subject\\Tools\\Tests\\test1");
    uft.setKillUftOnStartup(false);
    List<String> args = uft.prepareArguments(true, false);
    Assert.assertEquals(args.size(), 8);
    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("/server:http://almserver/qcbin"));
    Assert.assertTrue(args.get(3).equals("/user:usr"));
    Assert.assertTrue(args.get(4).equals("/password:pwd"));
    Assert.assertTrue(args.get(5).equals("/domain:dom"));
    Assert.assertTrue(args.get(6).equals("/project:proj"));
    Assert.assertTrue(args.get(7).equals("/load"));
}
Also used : 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 22 with Uft

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

the class TestUft method testPrepareLoadArgumentsWithKillOnStartup.

@Test(groups = { "ut" })
public void testPrepareLoadArgumentsWithKillOnStartup() {
    Uft uft = new Uft("D:\\Subject\\Tools\\Tests\\test1");
    uft.setKillUftOnStartup(true);
    List<String> args = uft.prepareArguments(true, false);
    Assert.assertEquals(args.size(), 4);
    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("D:\\Subject\\Tools\\Tests\\test1"));
    Assert.assertTrue(args.get(2).equals("/load"));
    Assert.assertTrue(args.get(3).equals("/clean"));
}
Also used : 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 23 with Uft

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

the class TestUft method testExecuteWithBom.

/**
 * Adding a character before XML report simulates the BOM
 * @throws Exception
 */
@Test(groups = { "ut" })
public void testExecuteWithBom() throws Exception {
    String report = GenericTest.readResourceToString("tu/uftReport.xml");
    report = "some comments\n_____OUTPUT_____B\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(5, new HashMap<>());
    // check a step is returned
    Assert.assertNotNull(testSteps);
    Assert.assertEquals(testSteps.get(0).getName(), "UFT: IP_Config_Poste_W10 [IP_Config_Poste_W10]");
}
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 24 with Uft

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

the class TestUft method testLoad.

@Test(groups = { "ut" })
public void testLoad() 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.setParameters(args);
    uft.loadScript(false);
    ArgumentCaptor<String[]> argsArgument = ArgumentCaptor.forClass(String[].class);
    PowerMockito.verifyStatic(TestTasks.class);
    TestTasks.executeCommand(eq("cscript.exe"), eq(60), isNull(), argsArgument.capture());
    // test parameters are not copied
    Assert.assertEquals(argsArgument.getAllValues().size(), 3);
    Assert.assertEquals(argsArgument.getAllValues().get(1), "[QualityCenter]Subject\\OUTILLAGE\\Tests_BHE\\test1");
    Assert.assertEquals(argsArgument.getAllValues().get(2), "/load");
}
Also used : 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 25 with Uft

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

the class TestUft method testExecuteNoLoad.

/**
 * Check we cannot execute a test if it's not loaded
 * @throws Exception
 */
@Test(groups = { "ut" }, expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "Test script has not been loaded. Call 'loadScript' before")
public void testExecuteNoLoad() 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);
    Uft uft = new Uft("[QualityCenter]Subject\\OUTILLAGE\\Tests_BHE\\test1");
    uft.executeScript(5, new HashMap<>());
}
Also used : Uft(com.seleniumtests.connectors.extools.Uft) 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