/**
  * Generate the test method as a string.
  *
  * @param bool                                      $shouldVerifyResult
  *
  * @param \Box\TestScribe\Execution\ExecutionResult $executionResult
  *
  * @return string
  */
 public function genResultValidation($shouldVerifyResult, ExecutionResult $executionResult)
 {
     if ($shouldVerifyResult) {
         $resultValue = $executionResult->getResultValue();
         $resultValidationStatements = $this->valueAssertionRenderer->generate('executionResult', $resultValue);
         $result = "// Validate the execution result.\n\n{$resultValidationStatements}";
     } else {
         $result = '';
     }
     return $result;
 }
 /**
  * Generate an OneSpec instance from the execution result.
  *
  * @param \Box\TestScribe\Execution\ExecutionResult $executionResult
  *
  * @return \Box\TestScribe\Spec\OneSpec
  */
 public function genSpecDetail(ExecutionResult $executionResult)
 {
     $testName = $this->globalComputedConfig->getTestMethodName();
     $result = $executionResult->getResultValue();
     $methodArguments = $executionResult->getMethodArguments();
     $methodParameters = $methodArguments->getValues();
     $constructorArguments = $executionResult->getConstructorArguments();
     $constructorParameters = $constructorArguments->getValues();
     $mockSpecs = $this->allMockSpecs->getAllMockSpecs();
     $oneSpec = new OneSpec($testName, $result, $constructorParameters, $methodParameters, $mockSpecs);
     return $oneSpec;
 }
Ejemplo n.º 3
0
 /**
  * @param \Box\TestScribe\Execution\ExecutionResult $result
  *
  * @return void
  */
 public function showExecutionResult(ExecutionResult $result)
 {
     $exception = $result->getException();
     if ($exception) {
         $exceptionType = get_class($exception);
         $exceptionMsg = $exception->getMessage();
         $resultMsg = "An exception ( {$exceptionType} ) is thrown.\n" . "Exception message ( {$exceptionMsg} ).";
     } else {
         $value = $result->getResultValue();
         // @TODO (ryang 6/4/15) : don't show the value if the return value of the method is void.
         $valueStr = $this->valueFormatter->getReadableFormat($value);
         $resultMsg = "Result from this method execution is :\n" . "{$valueStr}\n" . "End of the result.";
     }
     $msg = "{$resultMsg}\n\n" . "Please verify this result and the interactions with the mocks are what you expect.";
     $this->output->writeln($msg);
 }