Search in sources :

Example 6 with Uft

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

the class TestUft method testExecuteWithReport2.

/**
 * Check the case where UFT produces an invalid file
 * @throws Exception
 */
@Test(groups = { "ut" })
public void testExecuteWithReport2() throws Exception {
    String report = GenericTest.readResourceToString("tu/uftResult.txt");
    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, new HashMap<>());
    // check a step is returned
    Assert.assertNotNull(testSteps);
    Assert.assertEquals(testSteps.get(0).getName(), "UFT: Risques [Risques]");
    // check no HTML code is returned
    Assert.assertFalse(testSteps.toString().contains("<table>"));
}
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 7 with Uft

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

the class TestUft method testPrepareLoadArgumentsWithAlmTestMissingPasswordValues.

@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class)
public void testPrepareLoadArgumentsWithAlmTestMissingPasswordValues() {
    Uft uft = new Uft("http://almserver/qcbin", "usr", null, "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 8 with Uft

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

the class TestUft method testPrepareLoadArgumentsWithAlmTestMissingProjectValues.

@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class)
public void testPrepareLoadArgumentsWithAlmTestMissingProjectValues() {
    Uft uft = new Uft("http://almserver/qcbin", "usr", "pwd", "dom", null, "[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 9 with Uft

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

the class TestUft method testExecuteNoLoadBeforeSecondExecution.

/**
 * Check we cannot execute the same test twice if loading has not been done before the second execution
 * @throws Exception
 */
@Test(groups = { "ut" }, expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "Test script has not been loaded. Call 'loadScript' before")
public void testExecuteNoLoadBeforeSecondExecution() 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.loadScript(false);
    uft.executeScript(5, new HashMap<>());
    // try a second execution, it's not possible
    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)

Example 10 with Uft

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

the class TestUft method testPrepareArgumentsForGridNotThere.

/**
 * Test when grid is not present
 */
@Test(groups = { "ut" }, expectedExceptions = ScenarioException.class)
public void testPrepareArgumentsForGridNotThere() {
    SeleniumTestsContextManager.getThreadContext().setSeleniumGridConnector(null);
    SeleniumTestsContextManager.getThreadContext().setRunMode("grid");
    when(connector.uploadFileToNode(anyString(), eq(true))).thenReturn("D:\\file\\uft.vbs");
    Uft uft = new Uft("D:\\Subject\\Tools\\Tests\\test1");
    List<String> args = uft.prepareArguments(true, true);
}
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)

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