Search in sources :

Example 6 with TestVariable

use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.

the class TestTestTasks method testParamDoesNotExist.

/**
 * Check empty string is returned if parameter is not known
 */
@Test(groups = { "ut" })
public void testParamDoesNotExist() {
    SeleniumTestsContextManager.getThreadContext().getConfiguration().put("foo", new TestVariable("foo", "bar"));
    SeleniumTestsContextManager.getGlobalContext().getConfiguration().put("foo", new TestVariable("foo", "bar2"));
    Assert.assertEquals(TestTasks.param("foo2"), "");
}
Also used : TestVariable(com.seleniumtests.core.TestVariable) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) XmlTest(org.testng.xml.XmlTest) GenericTest(com.seleniumtests.GenericTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 7 with TestVariable

use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.

the class TestTestTasks method testParamKeyPattern.

/**
 * Check we get parameters with pattern on key from the thread context
 */
@Test(groups = { "ut" })
public void testParamKeyPattern() {
    SeleniumTestsContextManager.getThreadContext().getConfiguration().put("foofoo", new TestVariable("foofoo", "bar"));
    SeleniumTestsContextManager.getGlobalContext().getConfiguration().put("foofoo", new TestVariable("foofoo", "bar_global"));
    Assert.assertEquals(TestTasks.param(Pattern.compile("ofo")), "bar");
}
Also used : TestVariable(com.seleniumtests.core.TestVariable) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) XmlTest(org.testng.xml.XmlTest) GenericTest(com.seleniumtests.GenericTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 8 with TestVariable

use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.

the class TestTestVariable method testSimpleConstructor.

@Test(groups = { "ut" })
public void testSimpleConstructor() {
    TestVariable var = new TestVariable("key", "value");
    Assert.assertNull(var.getId());
    Assert.assertEquals(var.getInternalName(), var.getName());
    Assert.assertFalse(var.isReservable());
}
Also used : TestVariable(com.seleniumtests.core.TestVariable) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 9 with TestVariable

use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.

the class TestTestVariable method testFromJSonCustomVariable.

@Test(groups = { "ut" })
public void testFromJSonCustomVariable() {
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("id", 1);
    jsonObject.put("name", "custom.test.variable.key");
    jsonObject.put("value", "value");
    jsonObject.put("reservable", false);
    jsonObject.put("environment", 1);
    jsonObject.put("application", 2);
    jsonObject.put("version", 3);
    TestVariable var = TestVariable.fromJsonObject(jsonObject);
    Assert.assertEquals(var.getId(), (Integer) 1);
    Assert.assertEquals(var.getName(), "key");
    Assert.assertEquals(var.getValue(), "value");
    Assert.assertEquals(var.isReservable(), false);
    Assert.assertEquals(var.getInternalName(), "custom.test.variable.key");
    Assert.assertNull(var.getCreationDate());
}
Also used : JSONObject(kong.unirest.json.JSONObject) TestVariable(com.seleniumtests.core.TestVariable) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 10 with TestVariable

use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.

the class TestConfigReader method readConfigurationWithoutValueOverride.

@Test(groups = { "ut" })
public void readConfigurationWithoutValueOverride() {
    Map<String, TestVariable> config = new ConfigReader("VNR", null).readConfig(Thread.currentThread().getContextClassLoader().getResourceAsStream("tu/env.ini"));
    Assert.assertEquals(config.get("key1").getValue(), "value1", "Key should not be overriden");
}
Also used : ConfigReader(com.seleniumtests.core.config.ConfigReader) TestVariable(com.seleniumtests.core.TestVariable) XmlTest(org.testng.xml.XmlTest) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Aggregations

TestVariable (com.seleniumtests.core.TestVariable)72 Test (org.testng.annotations.Test)66 GenericTest (com.seleniumtests.GenericTest)53 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)38 XmlTest (org.testng.xml.XmlTest)34 ConnectorsTest (com.seleniumtests.ConnectorsTest)19 MockitoTest (com.seleniumtests.MockitoTest)19 ITestResult (org.testng.ITestResult)14 HashMap (java.util.HashMap)13 SeleniumRobotVariableServerConnector (com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)10 SeleniumTestsContext (com.seleniumtests.core.SeleniumTestsContext)7 File (java.io.File)3 ArrayList (java.util.ArrayList)3 JSONObject (kong.unirest.json.JSONObject)3 BrowserExtension (com.seleniumtests.browserfactory.BrowserExtension)2 ConfigReader (com.seleniumtests.core.config.ConfigReader)2 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)2 IOException (java.io.IOException)2 HttpRequest (kong.unirest.HttpRequest)2