Search in sources :

Example 1 with TestManager

use of com.seleniumtests.connectors.tms.TestManager in project seleniumRobot by bhecquet.

the class TestSeleniumTestContext3 method testInitTestManager.

@Test(groups = "ut")
public void testInitTestManager(final ITestContext testNGCtx, final XmlTest xmlTest) throws Exception {
    try {
        System.setProperty(SeleniumTestsContext.TMS_TYPE, "squash");
        System.setProperty(SeleniumTestsContext.TMS_URL, "http://localhost:1234");
        System.setProperty(SeleniumTestsContext.TMS_USER, "user");
        System.setProperty(SeleniumTestsContext.TMS_PASSWORD, "password");
        System.setProperty(SeleniumTestsContext.TMS_PROJECT, "project");
        // check that any parameter starting with "tms" will be used for configuration
        System.setProperty("tmsDomain", "domain");
        PowerMockito.mockStatic(TestManager.class);
        PowerMockito.when(TestManager.getInstance(argThat(config -> config.getString("tmsType").equals("squash") && config.getString("tmsDomain").equals("domain")))).thenReturn(testManager);
        ITestResult testResult = GenericTest.generateResult(testNGCtx, getClass());
        initThreadContext(testNGCtx, "myTest", testResult);
        // check test manager has been created
        Assert.assertEquals(SeleniumTestsContextManager.getThreadContext().getTestManagerInstance(), testManager);
    } finally {
        System.clearProperty(SeleniumTestsContext.TMS_TYPE);
        System.clearProperty(SeleniumTestsContext.TMS_URL);
        System.clearProperty(SeleniumTestsContext.TMS_USER);
        System.clearProperty(SeleniumTestsContext.TMS_PASSWORD);
        System.clearProperty(SeleniumTestsContext.TMS_PROJECT);
        System.clearProperty("tmsDomain");
    }
}
Also used : Arrays(java.util.Arrays) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Mock(org.mockito.Mock) TestManager(com.seleniumtests.connectors.tms.TestManager) HashMap(java.util.HashMap) Test(org.testng.annotations.Test) Mockito.spy(org.mockito.Mockito.spy) ITestResult(org.testng.ITestResult) SeleniumTestsContextManager(com.seleniumtests.core.SeleniumTestsContextManager) CucumberScenarioWrapper(com.seleniumtests.core.runner.CucumberScenarioWrapper) ConnectorsTest(com.seleniumtests.ConnectorsTest) JSONObject(org.json.JSONObject) SeleniumGridConnectorFactory(com.seleniumtests.connectors.selenium.SeleniumGridConnectorFactory) Assert(org.testng.Assert) ConfigurationException(com.seleniumtests.customexception.ConfigurationException) Map(java.util.Map) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) WebUIDriver(com.seleniumtests.driver.WebUIDriver) XmlTest(org.testng.xml.XmlTest) Mockito.doReturn(org.mockito.Mockito.doReturn) PowerMockito(org.powermock.api.mockito.PowerMockito) SeleniumTestsContext(com.seleniumtests.core.SeleniumTestsContext) ITestContext(org.testng.ITestContext) SeleniumGridConnector(com.seleniumtests.connectors.selenium.SeleniumGridConnector) Mockito.times(org.mockito.Mockito.times) TestVariable(com.seleniumtests.core.TestVariable) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) GenericTest(com.seleniumtests.GenericTest) SeleniumRobotVariableServerConnector(com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector) Mockito.any(org.mockito.Mockito.any) SessionId(org.openqa.selenium.remote.SessionId) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Mockito.mock(org.mockito.Mockito.mock) ITestResult(org.testng.ITestResult) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) XmlTest(org.testng.xml.XmlTest) GenericTest(com.seleniumtests.GenericTest)

Example 2 with TestManager

use of com.seleniumtests.connectors.tms.TestManager in project seleniumRobot by bhecquet.

the class TestTestManager method testTmsSelectionSquashTm.

@Test(groups = { "ut" })
public void testTmsSelectionSquashTm() {
    String config = "{'tmsType': 'squash'}";
    TestManager manager = TestManager.getInstance(new JSONObject(config));
    Assert.assertTrue(manager instanceof SquashTMConnector);
}
Also used : JSONObject(org.json.JSONObject) TestManager(com.seleniumtests.connectors.tms.TestManager) SquashTMConnector(com.seleniumtests.connectors.tms.squash.SquashTMConnector) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 3 with TestManager

use of com.seleniumtests.connectors.tms.TestManager in project seleniumRobot by bhecquet.

the class TestTestManager method testTmsSelectionHpAlm.

@Test(groups = { "ut" })
public void testTmsSelectionHpAlm() {
    String config = "{'tmsType': 'hp', 'tmsRun': '3'}";
    TestManager manager = TestManager.getInstance(new JSONObject(config));
    Assert.assertTrue(manager instanceof HpAlmConnector);
}
Also used : JSONObject(org.json.JSONObject) TestManager(com.seleniumtests.connectors.tms.TestManager) HpAlmConnector(com.seleniumtests.connectors.tms.hpalm.HpAlmConnector) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 4 with TestManager

use of com.seleniumtests.connectors.tms.TestManager in project seleniumRobot by bhecquet.

the class SeleniumTestsContext method initTestManager.

public TestManager initTestManager() {
    if (getTmsType() != null && getTmsUrl() != null) {
        // build configuration
        JSONObject jsonConfig = new JSONObject();
        jsonConfig.put(TMS_TYPE, getTmsType());
        jsonConfig.put(TMS_URL, getTmsUrl());
        jsonConfig.put(TMS_USER, getTmsUser());
        jsonConfig.put(TMS_PASSWORD, getTmsPassword());
        jsonConfig.put(TMS_PROJECT, getTmsProject());
        // add non standard configurations
        for (String key : getConfiguration().keySet()) {
            if (key.startsWith("tms")) {
                jsonConfig.put(key, getConfiguration().get(key).getValue());
            }
        }
        TestManager tms = TestManager.getInstance(jsonConfig);
        tms.init(jsonConfig);
        return tms;
    }
    return null;
}
Also used : JSONObject(org.json.JSONObject) TestManager(com.seleniumtests.connectors.tms.TestManager)

Example 5 with TestManager

use of com.seleniumtests.connectors.tms.TestManager in project seleniumRobot by bhecquet.

the class TestManagerReporter method generateReport.

@Override
protected void generateReport(Map<ITestContext, Set<ITestResult>> resultSet, String outdir, boolean optimizeResult, boolean finalGeneration) {
    // record only when all tests are executed so that intermediate results (a failed test which has been retried) are not present in list
    if (!finalGeneration) {
        return;
    }
    // Record test method reports for each result which has not already been recorded
    for (Map.Entry<ITestContext, Set<ITestResult>> entry : resultSet.entrySet()) {
        for (ITestResult testResult : entry.getValue()) {
            SeleniumTestsContext testContext = SeleniumTestsContextManager.setThreadContextFromTestResult(testResult.getTestContext(), testResult);
            TestManager testManager = testContext.getTestManagerInstance();
            if (testManager == null) {
                return;
            }
            testManager.login();
            // do not record twice the same result
            if (!TestNGResultUtils.isTestManagerReportCreated(testResult)) {
                testManager.recordResult(testResult);
                testManager.recordResultFiles(testResult);
                TestNGResultUtils.setTestManagereportCreated(testResult, true);
            }
            testManager.logout();
        }
    }
}
Also used : Set(java.util.Set) SeleniumTestsContext(com.seleniumtests.core.SeleniumTestsContext) ITestResult(org.testng.ITestResult) ITestContext(org.testng.ITestContext) TestManager(com.seleniumtests.connectors.tms.TestManager) Map(java.util.Map)

Aggregations

TestManager (com.seleniumtests.connectors.tms.TestManager)5 JSONObject (org.json.JSONObject)4 GenericTest (com.seleniumtests.GenericTest)3 Test (org.testng.annotations.Test)3 SeleniumTestsContext (com.seleniumtests.core.SeleniumTestsContext)2 Map (java.util.Map)2 ITestContext (org.testng.ITestContext)2 ITestResult (org.testng.ITestResult)2 ConnectorsTest (com.seleniumtests.ConnectorsTest)1 SeleniumGridConnector (com.seleniumtests.connectors.selenium.SeleniumGridConnector)1 SeleniumGridConnectorFactory (com.seleniumtests.connectors.selenium.SeleniumGridConnectorFactory)1 SeleniumRobotVariableServerConnector (com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector)1 HpAlmConnector (com.seleniumtests.connectors.tms.hpalm.HpAlmConnector)1 SquashTMConnector (com.seleniumtests.connectors.tms.squash.SquashTMConnector)1 SeleniumTestsContextManager (com.seleniumtests.core.SeleniumTestsContextManager)1 TestVariable (com.seleniumtests.core.TestVariable)1 CucumberScenarioWrapper (com.seleniumtests.core.runner.CucumberScenarioWrapper)1 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)1 WebUIDriver (com.seleniumtests.driver.WebUIDriver)1 Arrays (java.util.Arrays)1