use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class TestConfigReader method readConfigurationWithValueOverride.
@Test(groups = { "ut" })
public void readConfigurationWithValueOverride() {
Map<String, TestVariable> config = new ConfigReader("DEV", null).readConfig(Thread.currentThread().getContextClassLoader().getResourceAsStream("tu/env.ini"));
Assert.assertEquals(config.get("key1").getValue(), "value4", "Key override does not work");
}
use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class BugTrackerReporter method generateReport.
@Override
protected void generateReport(Map<ITestContext, Set<ITestResult>> resultSet, String outdir, boolean optimizeReport, boolean finalGeneration) {
for (Map.Entry<ITestContext, Set<ITestResult>> entry : resultSet.entrySet()) {
ITestContext context = entry.getKey();
for (ITestResult testResult : entry.getValue()) {
// record only when all executions of a test method are done so that intermediate results (a failed test which has been retried) are not present in list
if (!Boolean.TRUE.equals(TestNGResultUtils.getNoMoreRetry(testResult)) || TestNGResultUtils.isBugtrackerReportCreated(testResult)) {
continue;
}
// done in case it was null (issue #81)
SeleniumTestsContext testContext = SeleniumTestsContextManager.setThreadContextFromTestResult(context, testResult);
BugTracker bugtrackerServer = testContext.getBugTrackerInstance();
if (bugtrackerServer == null) {
return;
}
// get all bugtracker options
Map<String, String> issueOptions = new HashMap<>();
for (TestVariable variable : testContext.getConfiguration().values()) {
if (variable.getName().startsWith("bugtracker.")) {
issueOptions.put(variable.getName().replace("bugtracker.", ""), variable.getValue());
}
}
// application data
String application = testContext.getApplicationName();
String environment = testContext.getTestEnv();
String testNgName = testResult.getTestContext().getCurrentXmlTest().getName();
String testName = TestNGResultUtils.getUniqueTestName(testResult);
String description = String.format("Test '%s' failed\n", testName);
if (testResult.getMethod().getDescription() != null && !testResult.getMethod().getDescription().trim().isEmpty()) {
description += "Test goal: " + TestNGResultUtils.getTestDescription(testResult);
}
// search the last step to get screenshots and failure reason
List<TestStep> testSteps = TestNGResultUtils.getSeleniumRobotTestContext(testResult).getTestStepManager().getTestSteps();
if (testSteps == null) {
return;
}
// create issue only for failed tests and if it has not been created before
if (testResult.getStatus() == ITestResult.FAILURE) {
IssueBean issueBean = bugtrackerServer.createIssue(application, environment, testNgName, testName, description, testSteps, issueOptions);
// log information on issue
if (issueBean != null) {
if (issueBean.getId() != null && issueBean.getAccessUrl() != null) {
TestNGResultUtils.setTestInfo(testResult, "Issue", new HyperlinkInfo(issueBean.getId(), issueBean.getAccessUrl()));
} else if (issueBean.getId() != null) {
TestNGResultUtils.setTestInfo(testResult, "Issue", new StringInfo(issueBean.getId()));
}
TestNGResultUtils.setTestInfo(testResult, "Issue date", new StringInfo(issueBean.getCreationDate()));
}
TestNGResultUtils.setBugtrackerReportCreated(testResult, true);
// close issue if test is now OK and a previous issue has been created
} else if (testResult.getStatus() == ITestResult.SUCCESS) {
bugtrackerServer.closeIssue(application, environment, testNgName, testName);
TestNGResultUtils.setBugtrackerReportCreated(testResult, true);
}
}
}
}
use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class TestStringUtility method testInterpolateStringDoNotMaskPassword1.
@Test(groups = { "ut" })
public void testInterpolateStringDoNotMaskPassword1() {
SeleniumTestsContextManager.getThreadContext().getConfiguration().put("password", new TestVariable("password", "abc"));
Assert.assertEquals(StringUtility.interpolateString("connect with ${password}", SeleniumTestsContextManager.getThreadContext(), false), "connect with abc");
}
use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class TestStringUtility method testInterpolateStringDoNotMaskPassword.
@Test(groups = { "ut" })
public void testInterpolateStringDoNotMaskPassword() {
SeleniumTestsContextManager.getThreadContext().setMaskPassword(false);
SeleniumTestsContextManager.getThreadContext().getConfiguration().put("pwd", new TestVariable("pwd", "abc"));
Assert.assertEquals(StringUtility.interpolateString("connect with ${pwd}", SeleniumTestsContextManager.getThreadContext()), "connect with abc");
}
use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class TestStringUtility method testInterpolateString.
@Test(groups = { "ut" })
public void testInterpolateString() {
SeleniumTestsContextManager.getThreadContext().getConfiguration().put("url", new TestVariable("url", "http://mysite"));
Assert.assertEquals(StringUtility.interpolateString("connect to ${url}", SeleniumTestsContextManager.getThreadContext()), "connect to http://mysite");
}
Aggregations