Exemplo n.º 1
0
 /**
  * @group core
  */
 public function testCeptNamings()
 {
     $cept = new \Codeception\Test\Cept('Login', 'tests/acceptance/LoginCept.php');
     $this->assertEquals('tests/acceptance/LoginCept.php', \Codeception\Test\Descriptor::getTestFileName($cept));
     $this->assertEquals('tests/acceptance/LoginCept.php', \Codeception\Test\Descriptor::getTestFullName($cept));
     $this->assertEquals('LoginCept', \Codeception\Test\Descriptor::getTestSignature($cept));
 }
Exemplo n.º 2
0
 /**
  * @group core
  */
 public function testCestNamings()
 {
     $klass = new stdClass();
     $cest = new \Codeception\Test\Cest($klass, 'user', 'tests/acceptance/LoginCest.php');
     $this->assertEquals('tests/acceptance/LoginCest.php:user', \Codeception\Test\Descriptor::getTestFullName($cest));
     $this->assertEquals('tests/acceptance/LoginCest.php', \Codeception\Test\Descriptor::getTestFileName($cest));
     $this->assertEquals('stdClass:user', \Codeception\Test\Descriptor::getTestSignature($cest));
 }
Exemplo n.º 3
0
 public function saveFailed(PrintResultEvent $e)
 {
     $file = $this->getLogDir() . $this->config['file'];
     $result = $e->getResult();
     if ($result->wasSuccessful()) {
         if (is_file($file)) {
             unlink($file);
         }
         return;
     }
     $output = [];
     foreach ($result->failures() as $fail) {
         $output[] = $this->localizePath(Descriptor::getTestFullName($fail->failedTest()));
     }
     foreach ($result->errors() as $fail) {
         $output[] = $this->localizePath(Descriptor::getTestFullName($fail->failedTest()));
     }
     file_put_contents($file, implode("\n", $output));
 }
 public function run()
 {
     if (!class_exists('\\Codeception\\Test\\Loader')) {
         throw new TaskException($this, "This task requires Codeception to be loaded. Please require autoload.php of Codeception");
     }
     $testLoader = new \Codeception\Test\Loader(['path' => $this->testsFrom]);
     $testLoader->loadTests($this->testsFrom);
     $tests = $testLoader->getTests();
     $i = 0;
     $groups = [];
     $this->printTaskInfo("Processing " . count($tests) . " tests");
     // splitting tests by groups
     foreach ($tests as $test) {
         $groups[$i % $this->numGroups + 1][] = \Codeception\Test\Descriptor::getTestFullName($test);
         $i++;
     }
     // saving group files
     foreach ($groups as $i => $tests) {
         $filename = $this->saveTo . $i;
         $this->printTaskInfo("Writing {$filename}");
         file_put_contents($filename, implode("\n", $tests));
     }
 }
Exemplo n.º 5
0
 public function printFail(FailEvent $e)
 {
     $failedTest = $e->getTest();
     $fail = $e->getFail();
     $this->output->write($e->getCount() . ") ");
     $this->writeCurrentTest($failedTest, false);
     $this->output->writeln('');
     $this->message("<error> Test </error> ")->append(codecept_relative_path(Descriptor::getTestFullName($failedTest)))->write();
     if ($failedTest instanceof ScenarioDriven) {
         $this->printScenarioFail($failedTest, $fail);
         return;
     }
     $this->printException($fail);
     $this->printExceptionTrace($fail);
 }
Exemplo n.º 6
0
 protected function checkEnvironmentExists(TestInterface $test)
 {
     $envs = $test->getMetadata()->getEnv();
     if (empty($envs)) {
         return;
     }
     if (!isset($this->settings['env'])) {
         Notification::warning("Environments are not configured", Descriptor::getTestFullName($test));
         return;
     }
     $availableEnvironments = array_keys($this->settings['env']);
     $listedEnvironments = explode(',', implode(',', $envs));
     foreach ($listedEnvironments as $env) {
         if (!in_array($env, $availableEnvironments)) {
             Notification::warning("Environment {$env} was not configured but used in test", Descriptor::getTestFullName($test));
         }
     }
 }