From 3902ca6332db6f827651ec55edecc4c171ee7675 Mon Sep 17 00:00:00 2001 From: puneet0191 Date: Sat, 31 Oct 2015 21:34:54 +0530 Subject: [PATCH] Updating Robo File to add the functionality to run each method. --- RoboFile.php | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/RoboFile.php b/RoboFile.php index 1dc93c9..751824c 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -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(); + } } /**