use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.
the class TestsuiteRunner method runSuites.
public EnvironmentRunResult runSuites(List<TestSuiteEntity> testCaseGroupEntities) throws AutomatorException {
log.debug("----- Running Test Suites For Environment Run Result [" + environmentRunResult.getId() + "] -----");
List<TestSuiteResult> testCaseGroupsResults = new ArrayList<TestSuiteResult>();
environmentRunResult.setGroupResults(testCaseGroupsResults);
ResultConstant result = ResultConstant.SUCCESS;
for (TestSuiteEntity testSuiteEntity : testCaseGroupEntities) {
skipExecution = false;
resultFailureMessage = null;
TestSuiteResult testSuiteResult = new TestSuiteResult();
testSuiteResult.setId(testSuiteEntity.getResultId());
testSuiteResult.setGroupId(testSuiteEntity.getId());
testSuiteResult.setEnvRunId(testSuiteEntity.getEnvironmentResultId());
testSuiteResult.setExecutionInitiatedOn(environmentRunResult.getExecutionInitiatedOn());
testSuiteResult.setAgentPickedOn(environmentRunResult.getAgentPickedOn());
testSuiteResult.setDeviceAllocatedOn(environmentRunResult.getDeviceAllocatedOn());
testCaseGroupsResults.add(testSuiteResult);
groupResultMap.put(testSuiteEntity.getId(), testSuiteResult);
testSuiteResult.setStartTime(new Timestamp(System.currentTimeMillis()));
try {
log.debug("Running Test Suite - " + testSuiteEntity);
try {
checkSuitePrerequisiteFailure(testSuiteEntity, testSuiteResult);
if (ExecutionEnvironmentRunner.isRunning()) {
log.debug("Execution environment status is running...Proceeding with the test suite execution....");
runSuite(testSuiteEntity, testSuiteResult);
} else {
log.debug("Execution environment status is stopped...stopping test suite execution....");
testSuiteResult.setResult(ResultConstant.STOPPED);
testSuiteResult.setMessage(AutomatorMessages.MSG_USER_ABORTED_EXECUTION);
testSuiteResult.setEndTime(new Timestamp(System.currentTimeMillis()));
postSuiteResult(testSuiteResult);
break;
}
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
testSuiteResult.setResult(ResultConstant.FAILURE);
testSuiteResult.setMessage(ex.getMessage());
}
testSuiteResult.setEndTime(new Timestamp(System.currentTimeMillis()));
postSuiteResult(testSuiteResult);
} catch (Exception ex) {
log.error("Unhandled exception while processing test suite");
log.error(ex.getMessage(), ex);
testSuiteResult.setEndTime(new Timestamp(System.currentTimeMillis()));
testSuiteResult.setResult(ResultConstant.FAILURE);
testSuiteResult.setMessage(ex.getMessage());
try {
postSuiteResult(testSuiteResult);
} catch (Exception e) {
log.error("Unhandled exception while sending test suite results");
log.error(e.getMessage(), e);
}
}
if (testSuiteResult.getResult().getId() > result.getId()) {
result = testSuiteResult.getResult();
}
}
if (environmentRunResult.getResult() == null) {
environmentRunResult.setResult(result);
}
return environmentRunResult;
}
use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.
the class AppInstaller method installApp.
public String installApp(String deviceName, String deviceUniqueId, String appUrl) throws AutomatorException {
File appFile = null;
log.info(String.format("Install app %s on device %s", appUrl, deviceName));
try {
appFile = downloadApp(appUrl);
String bundleId = getAppBundleId(appFile);
Process p = iosDeviceCommandExecutor.runDeviceCommand(new String[] { "-u", deviceUniqueId, "install", appFile.getAbsolutePath() });
p.waitFor(60, TimeUnit.SECONDS);
String installOutput = iosDeviceCommandExecutor.getProcessStreamResponse(p);
log.info(installOutput);
boolean installed = checkIfInstalled(deviceName, deviceUniqueId, bundleId);
if (installed) {
return bundleId;
} else {
throw new AutomatorException("App not installed on device", "App not installed on device");
}
} catch (Exception e) {
throw new AutomatorException(e.getMessage(), e);
} finally {
if ((appFile != null) && appFile.exists()) {
boolean deleted = appFile.delete();
if (!deleted) {
log.error("Unable to delete temp app file - " + appFile.getAbsolutePath());
}
}
}
}
use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.
the class IosDeviceCommandExecutor method runDeviceCommand.
public Process runDeviceCommand(String[] subCommand) throws AutomatorException {
try {
String[] command = ArrayUtils.addAll(new String[] { getIosIdeviceExecutablePath() }, subCommand);
log.debug("Running a idevice command - " + Arrays.toString(command));
ProcessBuilder processBuilder = new ProcessBuilder(command);
return processBuilder.start();
} catch (Exception e) {
throw new AutomatorException(e.getMessage());
}
}
use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.
the class ExecutionEnvironmentRunner method checkForEmptyEnvironment.
public void checkForEmptyEnvironment() throws AutomatorException {
boolean isEmpty = true;
for (TestSuiteEntity entity : testDeviceEntity.getTestSuites()) {
if (entity.getTestCases().size() > 0) {
isEmpty = false;
break;
}
}
if (isEmpty) {
AutomatorException ex = new AutomatorException(AutomatorMessages.NO_TESTCASES_AVAILABLE, AutomatorMessages.NO_TESTCASES_AVAILABLE);
ex.setDispMessage(AutomatorMessages.NO_TESTCASES_AVAILABLE);
throw ex;
}
}
use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.
the class StandaloneAppBridge method updateRunTimeData.
@Override
public void updateRunTimeData(Long environmentResultId, RuntimeEntity runtimeEntity) throws AutomatorException {
try {
RuntimeRequest runtimeRequest = convertToObject(runtimeEntity, RuntimeRequest.class);
runTimeDataService.updateRunTimeData(environmentResultId, runtimeRequest);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new AutomatorException(e.getMessage(), e);
}
}
Aggregations