Updating Robo File to add the functionality to run each method.

This commit is contained in:
puneet0191 2015-10-31 21:34:54 +05:30
parent b1c3dee301
commit 3902ca6332
1 changed files with 59 additions and 1 deletions

View File

@ -155,12 +155,70 @@ class RoboFile extends \Robo\Tasks
$pathToTestFile = 'tests/' . $suite . '/' . $test;
$this->taskCodecept()
//loading the class to display the methods in the class
require 'tests/' . $suite . '/' . $test;
//logic to fetch the class name from the file name
$fileName = explode("/", $test);
$className = explode(".", $fileName[1]);
//if the selected file is cest only than we will give the option to execute individual methods, we don't need this in cept file
$i = 1;
if (strripos($className[0], 'cest'))
{
$class_methods = get_class_methods($className[0]);
$this->say('[' . $i . '] ' . 'All');
$methods[$i] = 'All';
$i++;
foreach ($class_methods as $method_name)
{
$reflect = new ReflectionMethod($className[0], $method_name);
if(!$reflect->isConstructor())
{
if ($reflect->isPublic())
{
$this->say('[' . $i . '] ' . $method_name);
$methods[$i] = $method_name;
$i++;
}
}
}
$this->say('');
$methodNumber = $this->ask('Please choose the method in the test that you would want to run...');
$method = $methods[$methodNumber];
}
if(isset($method))
{
if($method != 'All')
{
$this->taskCodecept()
->test($pathToTestFile . ':' . $method)
->arg('--steps')
->arg('--debug')
->run()
->stopOnFail();
}
else
{
$this->taskCodecept()
->test($pathToTestFile)
->arg('--steps')
->arg('--debug')
->run()
->stopOnFail();
}
}
else
{
$this->taskCodecept()
->test($pathToTestFile)
->arg('--steps')
->arg('--debug')
->run()
->stopOnFail();
}
}
/**