Skip to content

Commit 283e94f

Browse files
committed
MQE-2042: Port MFTF Coverage to Jenkins
1 parent 4267fee commit 283e94f

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ class TestContextExtension extends BaseExtension
3232
*/
3333
public static $events;
3434

35+
/**
36+
* The name of the currently running test
37+
* @var string
38+
*/
39+
public $currentTest;
40+
3541
/**
3642
* Initialize local vars
3743
*
@@ -55,8 +61,20 @@ public function _initialize()
5561
* @throws \Exception
5662
* @return void
5763
*/
58-
public function testStart()
64+
public function testStart(\Codeception\Event\TestEvent $e)
5965
{
66+
if (getenv('ENABLE_CODE_COVERAGE') === 'true') {
67+
// Curl against test.php and pass in the test name. Used when gathering code coverage.
68+
$this->currentTest = $e->getTest()->getMetadata()->getName();
69+
$cURLConnection = curl_init();
70+
curl_setopt_array($cURLConnection, [
71+
CURLOPT_RETURNTRANSFER => 1,
72+
CURLOPT_URL => getenv('MAGENTO_BASE_URL') . "/test.php?test=" . $this->currentTest,
73+
]);
74+
curl_exec($cURLConnection);
75+
curl_close($cURLConnection);
76+
}
77+
6078
PersistedObjectHandler::getInstance()->clearHookObjects();
6179
PersistedObjectHandler::getInstance()->clearTestObjects();
6280
}

0 commit comments

Comments
 (0)