How to use executeStep method of org.cerberus.engine.execution.impl.ExecutionRunService class

Best Cerberus-source code snippet using org.cerberus.engine.execution.impl.ExecutionRunService.executeStep

Source:ExecutionRunService.java Github

copy

Full Screen

...492 if (execute_Step) {493 /**494 * We execute the step495 */496 testCaseStepExecution = this.executeStep(testCaseStepExecution, tCExecution);497 /**498 * Updating Execution Result Message only if499 * execution result message of the step is not500 * PE or OK.501 */502 if ((!(testCaseStepExecution.getExecutionResultMessage().equals(new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_TESTSTARTED))))503 && (!(testCaseStepExecution.getExecutionResultMessage().equals(new MessageGeneral(MessageGeneralEnum.EXECUTION_OK))))) {504 tCExecution.setResultMessage(testCaseStepExecution.getExecutionResultMessage());505 }506 if (testCaseStepExecution.getStepResultMessage().equals(new MessageEvent(MessageEventEnum.STEP_PENDING))) {507 testCaseStepExecution.setStepResultMessage(new MessageEvent(MessageEventEnum.STEP_SUCCESS));508 }509 testCaseStepExecutionService.updateTestCaseStepExecution(testCaseStepExecution);510 if (testCaseStepExecution.isStopExecution()) {511 break;512 }513 } else // We don't execute the step and record a generic execution.514 if ((!conditionStepDecodeError) && (!conditionStepError)) {515 /**516 * Register Step in database517 */518 LOG.debug("Registering Step : " + testCaseStepExecution.getStep());519 // We change the Step message only if the Step is not executed due to condition.520 MessageEvent stepMes = new MessageEvent(MessageEventEnum.CONDITION_TESTCASESTEP_NOTEXECUTED);521 testCaseStepExecution.setStepResultMessage(stepMes);522 testCaseStepExecution.setReturnMessage(testCaseStepExecution.getReturnMessage()523 .replace("%COND%", testCaseStepExecution.getConditionOper())524 .replace("%LOOP%", testCaseStepExecution.getLoop())525 .replace("%MESSAGE%", conditionAnswer.getResultMessage().getDescription())526 );527 testCaseStepExecution.setEnd(new Date().getTime());528 this.testCaseStepExecutionService.updateTestCaseStepExecution(testCaseStepExecution);529 LOG.debug("Registered Step");530 } else {531 // Not executed because decode error or failed condition.532 testCaseStepExecution.setEnd(new Date().getTime());533 testCaseStepExecution.setStopExecution(true);534 this.testCaseStepExecutionService.updateTestCaseStepExecution(testCaseStepExecution);535 LOG.debug("Registered Step");536 }537 /**538 * Log TestCaseStepExecution539 */540 if (tCExecution.getVerbose() > 0) {541 LOG.info(testCaseStepExecution.toJson(false, true));542 }543 // Websocket --> we refresh the corresponding Detail Execution pages attached to this execution.544 if (tCExecution.isCerberus_featureflipping_activatewebsocketpush()) {545 TestCaseExecutionEndPoint.getInstance().send(tCExecution, false);546 }547 step_index++;548 } while (execute_Next_Step && step_index <= maxloop);549 if (testCaseStepExecution.isStopExecution()) {550 break;551 }552 }553 /**554 * If at that time the execution is still PE, we move it to555 * OK. It means that no issue were met.556 */557 if ((tCExecution.getResultMessage() == null) || (tCExecution.getResultMessage().equals(new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_TESTSTARTED)))) {558 tCExecution.setResultMessage(new MessageGeneral(MessageGeneralEnum.EXECUTION_OK));559 }560 /**561 * We record Selenium log at the end of the execution.562 */563 try {564 tCExecution.addFileList(recorderService.recordSeleniumLog(tCExecution));565 } catch (Exception ex) {566 LOG.error(logPrefix + "Exception Getting Selenium Logs " + tCExecution.getId() + " Exception :" + ex.toString());567 }568 } else { // We don't execute the testcase linked with condition.569 MessageGeneral mes;570 /**571 * Update Execution status from condition572 */573 if (conditionAnswerTc.getResultMessage().getMessage().getCodeString().equals("PE")) {574 mes = new MessageGeneral(MessageGeneralEnum.EXECUTION_NA_CONDITION);575 } else {576 mes = new MessageGeneral(MessageGeneralEnum.EXECUTION_FA_CONDITION);577 }578 mes.setDescription(mes.getDescription().replace("%COND%", tCExecution.getConditionOper())579 .replace("%MES%", conditionAnswerTc.getResultMessage().getDescription()));580 tCExecution.setResultMessage(mes);581 }582 }583 } catch (Exception ex) {584 /**585 * If an exception is found, set the execution to FA and print the586 * exception587 */588 tCExecution.setResultMessage(new MessageGeneral(MessageGeneralEnum.EXECUTION_FA));589 tCExecution.setControlMessage(tCExecution.getControlMessage() + " Exception: " + ex);590 LOG.error(logPrefix + "Exception found Executing Test " + tCExecution.getId() + " Exception :" + ex.toString());591 } finally {592 /**593 * We stop the server session here (selenium for ex.).594 */595 try {596 tCExecution = this.stopTestCase(tCExecution);597 } catch (Exception ex) {598 LOG.error(logPrefix + "Exception Stopping Test " + tCExecution.getId() + " Exception :" + ex.toString());599 }600 /**601 * Log Execution602 */603 LOG.info(tCExecution.toJson(false));604 /**605 * Clean memory606 */607 try {608 executionUUID.removeExecutionUUID(tCExecution.getExecutionUUID());609 LOG.debug("Clean ExecutionUUID");610 } catch (Exception ex) {611 LOG.error("Exception cleaning Memory: " + ex.toString());612 }613 /**614 * Log execution is finished615 */616 LOG.info("Execution Finished : UUID=" + tCExecution.getExecutionUUID()617 + "__ID=" + tCExecution.getId() + "__RC=" + tCExecution.getControlStatus() + "__"618 + "TestName=" + tCExecution.getEnvironment() + "." + tCExecution.getCountry() + "."619 + tCExecution.getBuild() + "." + tCExecution.getRevision() + "." + tCExecution.getTest() + "_"620 + tCExecution.getTestCase() + "_" + tCExecution.getTestCaseObj().getDescription().replace(".", ""));621 /**622 * Updating queue to done status only for execution from queue623 */624 if (tCExecution.getQueueID() != 0) {625 executionQueueService.updateToDone(tCExecution.getQueueID(), "", runID);626 }627 /**628 * Retry management, in case the result is not (OK or NE), we629 * execute the job again reducing the retry to 1.630 */631 if (tCExecution.getNumberOfRetries() > 0632 && !tCExecution.getResultMessage().getCodeString().equals("OK")633 && !tCExecution.getResultMessage().getCodeString().equals("NE")) {634 TestCaseExecutionQueue newExeQueue = new TestCaseExecutionQueue();635 if (tCExecution.getQueueID() > 0) {636 // If QueueId exist, we try to get the original execution queue.637 try {638 newExeQueue = executionQueueService.convert(executionQueueService.readByKey(tCExecution.getQueueID()));639 } catch (Exception e) {640 // Unfortunatly the execution no longuer exist so we pick initial value.641 newExeQueue = tCExecution.getTestCaseExecutionQueue();642 }643 } else {644 // Initial Execution does not come from the queue so we pick the value created at the beginning of the execution.645 newExeQueue = tCExecution.getTestCaseExecutionQueue();646 }647 // Forcing init value for that new queue execution : exeid=0, no debugflag and State = QUEUED648 int newRetry = tCExecution.getNumberOfRetries() - 1;649 newExeQueue.setId(0);650 newExeQueue.setDebugFlag("N");651 if (newRetry <= 0) {652 newExeQueue.setComment("Added from Retry. Last attempt to go.");653 } else {654 newExeQueue.setComment("Added from Retry. Still " + newRetry + " attempt(s) to go.");655 }656 newExeQueue.setState(TestCaseExecutionQueue.State.QUEUED);657 newExeQueue.setRetries(newRetry);658 // Insert execution to the Queue.659 executionQueueService.create(newExeQueue);660 }661 /**662 * After every execution finished, <br>663 * if the execution has a tag that has a campaign associated <br>664 * and no more executions are in the queue, <br>665 * we trigger : <br>666 * 1/ The update of the EndExeQueue of the tag <br>667 * 2/ We notify the Distribution List with execution report status668 */669 try {670 if (!StringUtil.isNullOrEmpty(tCExecution.getTag())) {671 Tag currentTag = tagService.convert(tagService.readByKey(tCExecution.getTag()));672 if ((currentTag != null)) {673 if (currentTag.getDateEndQueue().before(Timestamp.valueOf("1980-01-01 01:01:01.000000001"))) {674 AnswerList answerListQueue = new AnswerList();675 answerListQueue = executionQueueService.readQueueOpen(tCExecution.getTag());676 if (answerListQueue.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) && (answerListQueue.getDataList().isEmpty())) {677 LOG.debug("No More executions in (queue) on tag : " + tCExecution.getTag() + " - " + answerListQueue.getDataList().size() + " " + answerListQueue.getMessageCodeString() + " - ");678 tagService.updateDateEndQueue(tCExecution.getTag(), new Timestamp(new Date().getTime()));679 if (!StringUtil.isNullOrEmpty(currentTag.getCampaign())) {680 // We get the campaig here and potencially send the notification.681 emailService.generateAndSendNotifyEndTagExecution(tCExecution.getTag(), currentTag.getCampaign());682 }683 } else {684 LOG.debug("Still executions in queue on tag : " + tCExecution.getTag() + " - " + answerListQueue.getDataList().size() + " " + answerListQueue.getMessageCodeString());685 }686 } else {687 LOG.debug("Tag is already flaged with recent timstamp. " + currentTag.getDateEndQueue());688 }689 }690 }691 } catch (Exception e) {692 LOG.error(e);693 }694 //695 // After every execution finished we try to trigger more from the queue;-).696 executionThreadPoolService.executeNextInQueueAsynchroneously(false);697 }698 return tCExecution;699 }700 @Override701 public TestCaseExecution stopTestCase(TestCaseExecution tCExecution) {702 /**703 * Stop Execution704 */705 LOG.debug(tCExecution.getId() + " - Stop the execution " + tCExecution.getId() + " UUID:" + tCExecution.getExecutionUUID());706 try {707 //TODO:FN debug messages to be removed708 LOG.debug("[DEBUG] STOP " + "__ID=" + tCExecution.getId());709 this.stopRunTestCase(tCExecution);710 } catch (Exception ex) {711 LOG.warn("Exception Stopping Execution " + tCExecution.getId() + " Exception :" + ex.toString());712 }713 /**714 * Collecting and calculating Statistics.715 */716 try {717// this.collectExecutionStats(tCExecution);718 } catch (Exception ex) {719 LOG.warn("Exception collecting stats for execution " + tCExecution.getId() + " Exception:" + ex.toString());720 }721 /**722 * Saving TestCaseExecution object.723 */724 tCExecution.setEnd(new Date().getTime());725 try {726 testCaseExecutionService.updateTCExecution(tCExecution);727 } catch (CerberusException ex) {728 LOG.warn("Exception updating Execution :" + tCExecution.getId() + " Exception:" + ex.toString());729 }730 // Websocket --> we refresh the corresponding Detail Execution pages attached to this execution.731 if (tCExecution.isCerberus_featureflipping_activatewebsocketpush()) {732 TestCaseExecutionEndPoint.getInstance().send(tCExecution, true);733 TestCaseExecutionEndPoint.getInstance().end(tCExecution);734 }735 return tCExecution;736 }737 private TestCaseStepExecution executeStep(TestCaseStepExecution testCaseStepExecution, TestCaseExecution tcExecution) {738 long runID = testCaseStepExecution.getId();739 String logPrefix = runID + " - ";740 AnswerItem<String> answerDecode = new AnswerItem();741 // Initialise the Step Data List.742 List<TestCaseExecutionData> myStepDataList = new ArrayList<TestCaseExecutionData>();743 testCaseStepExecution.setTestCaseExecutionDataList(myStepDataList);744 // Initialise the Data List used to enter the action.745 /**746 * Iterate Actions747 */748 List<TestCaseStepAction> testCaseStepActionList = testCaseStepExecution.getTestCaseStep().getTestCaseStepAction();749 LOG.debug("Getting list of actions of the step. " + testCaseStepActionList.size() + " action(s) to perform.");750 for (TestCaseStepAction testCaseStepAction : testCaseStepActionList) {751 /**...

Full Screen

Full Screen

executeStep

Using AI Code Generation

copy

Full Screen

1import org.cerberus.engine.execution.impl.ExecutionRunService2import org.cerberus.engine.execution.impl.ExecuteStepService3import org.cerberus.engine.execution.impl.ExecuteTestCaseService4import org.cerberus.engine.execution.impl.ExecuteTestService5import org.cerberus.engine.execution.impl.ExecuteTestSuiteService6import org.cerberus.engine.entity.MessageGeneral7import org.cerberus.engine.entity.MessageEvent8import org.cerberus.engine.entity.Session9import org.cerberus.engine.entity.MessageGeneralEnum10import org.cerbe

Full Screen

Full Screen

executeStep

Using AI Code Generation

copy

Full Screen

1 def executeStep = { String stepId, String stepAction, String stepProperty, String stepValue, String stepConditionOperator, String stepConditionValue1, String stepConditionValue2, String stepConditionValue3, String stepConditionValue4, String stepConditionValue5, String stepConditionValue6, String stepConditionValue7, String stepConditionValue8, String stepConditionValue9, String stepConditionValue10, String stepConditionValue11, String stepConditionValue12, String stepConditionValue13, String stepConditionValue14, String stepConditionValue15, String stepConditionValue16, String stepConditionValue17, String stepConditionValue18, String stepConditionValue19, String stepConditionValue20, String stepConditionValue21, String stepConditionValue22, String stepConditionValue23, String stepConditionValue24, String stepConditionValue25, String stepConditionValue26, String stepConditionValue27, String stepConditionValue28, String stepConditionValue29, String stepConditionValue30 ->2 def step = new Step()3 step.setStepId(stepId)4 step.setStepAction(stepAction)5 step.setStepProperty(stepProperty)6 step.setStepValue(stepValue)7 step.setStepConditionOperator(stepConditionOperator)8 step.setStepConditionValue1(stepConditionValue1)9 step.setStepConditionValue2(stepConditionValue2)10 step.setStepConditionValue3(stepConditionValue3)11 step.setStepConditionValue4(stepConditionValue4)12 step.setStepConditionValue5(stepConditionValue5)13 step.setStepConditionValue6(stepConditionValue6)14 step.setStepConditionValue7(stepConditionValue7)15 step.setStepConditionValue8(stepConditionValue8)16 step.setStepConditionValue9(stepConditionValue9)17 step.setStepConditionValue10(stepConditionValue10)18 step.setStepConditionValue11(stepConditionValue11)19 step.setStepConditionValue12(stepConditionValue12)20 step.setStepConditionValue13(stepConditionValue13)21 step.setStepConditionValue14(stepConditionValue14)22 step.setStepConditionValue15(stepConditionValue15)23 step.setStepConditionValue16(stepConditionValue16)24 step.setStepConditionValue17(stepConditionValue17)25 step.setStepConditionValue18(stepConditionValue18)26 step.setStepConditionValue19(stepConditionValue19)27 step.setStepConditionValue20(stepConditionValue20)

Full Screen

Full Screen

executeStep

Using AI Code Generation

copy

Full Screen

1import org.cerberus.engine.execution.impl.ExecutionRunService2import org.cerberus.engine.entity.MessageGeneral3import org.cerberus.engine.entity.MessageEvent4import org.cerberus.engine.entity.MessageEventEnum5def executionRunService = new ExecutionRunService()6def result = executionRunService.executeStep(test, testCase, country, null)7def resultMessage = result.getResultMessage()8def messageGeneral = resultMessage.resolveDescriptionOrBuildMessage("", null)9def messageEvent = resultMessage.resolveDescriptionOrBuildMessage("", null)10if (messageEvent != null) {11 println(messageEvent.getCode() + " " + messageEvent.getDescription())12}13if (messageGeneral != null) {14 println(messageGeneral.getCode() + " " + messageGeneral.getDescription())15}16if (messageEvent == null) {17} else {18}19if (messageGeneral == null) {20} else {21}22if (messageEvent == null) {23} else {24}25if (messageGeneral == null) {26} else {27}28if (messageEvent == null) {29} else {30}31if (messageGeneral == null) {32} else {33}34if (messageEvent == null) {35} else {36}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Cerberus-source automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful