Skip to content

MQE-1178: MFTF Generate:Suite Does Not Generate Extended Items Correctly #270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dev/tests/_bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@

$paths = [
$suiteDirectory . DIRECTORY_SEPARATOR . 'functionalSuite.xml',
$suiteDirectory . DIRECTORY_SEPARATOR . 'functionalSuiteHooks.xml'
$suiteDirectory . DIRECTORY_SEPARATOR . 'functionalSuiteHooks.xml',
$suiteDirectory . DIRECTORY_SEPARATOR . 'functionalSuiteExtends.xml'
];

// create and return the iterator for these file paths
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
namespace Magento\AcceptanceTest\_suiteExtends\Backend;

use Magento\FunctionalTestingFramework\AcceptanceTester;
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore;
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler;
use \Codeception\Util\Locator;
use Yandex\Allure\Adapter\Annotation\Features;
use Yandex\Allure\Adapter\Annotation\Stories;
use Yandex\Allure\Adapter\Annotation\Title;
use Yandex\Allure\Adapter\Annotation\Description;
use Yandex\Allure\Adapter\Annotation\Parameter;
use Yandex\Allure\Adapter\Annotation\Severity;
use Yandex\Allure\Adapter\Model\SeverityLevel;
use Yandex\Allure\Adapter\Annotation\TestCaseId;

/**
* @Title("[NO TESTCASEID]: ExtendedTestInSuiteChildTest")
* @group ExtendedTestInSuiteChildTest
*/
class ExtendedTestInSuiteChildTestCest
{
/**
* @param AcceptanceTester $I
* @throws \Exception
*/
public function _before(AcceptanceTester $I)
{
$I->amOnPage("/beforeUrl");
}

/**
* @param AcceptanceTester $I
* @throws \Exception
*/
public function _after(AcceptanceTester $I)
{
$I->amOnPage("/afterUrl");
}

/**
* @param AcceptanceTester $I
* @throws \Exception
*/
public function _failed(AcceptanceTester $I)
{
$I->saveScreenshot();
}

/**
* @Severity(level = SeverityLevel::TRIVIAL)
* @Features({"TestModule"})
* @Stories({"ExtendedTestInSuiteChildTest"})
* @Parameter(name = "AcceptanceTester", value="$I")
* @param AcceptanceTester $I
* @return void
* @throws \Exception
*/
public function ExtendedTestInSuiteChildTest(AcceptanceTester $I)
{
$I->comment("Different Input");
}
}
28 changes: 28 additions & 0 deletions dev/tests/verification/TestModule/Test/ExtendedFunctionalTest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,32 @@
</annotations>
<comment userInput="child" stepKey="replaceMe"/>
</test>

<test name="ExtendedTestInSuiteParentTest">
<annotations>
<severity value="AVERAGE"/>
<title value="ExtendedTestInSuiteParentTest"/>
<group value="ExtendedTestInSuite"/>
<features value="ExtendedTestInSuite"/>
<stories value="ExtendedTestInSuite"/>
</annotations>
<before>
<amOnPage url="/beforeUrl" stepKey="beforeAmOnPageKey"/>
</before>
<after>
<amOnPage url="/afterUrl" stepKey="afterAmOnPageKey"/>
</after>
<comment stepKey="basicCommentWithNoData" userInput="Parent Comment"/>
</test>

<test name="ExtendedTestInSuiteChildTest" extends="ExtendedTestInSuiteParentTest">
<annotations>
<severity value="MINOR"/>
<title value="ExtendedTestInSuiteChildTest"/>
<group value="ExtendedTestInSuiteChildTest"/>
<features value="ExtendedTestInSuiteChildTest"/>
<stories value="ExtendedTestInSuiteChildTest"/>
</annotations>
<comment stepKey="basicCommentWithNoData" userInput="Different Input"/>
</test>
</tests>
39 changes: 39 additions & 0 deletions dev/tests/verification/Tests/SuiteGenerationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,45 @@ public function testSuiteGenerationSingleRun()
$this->assertEquals($expectedManifest, file_get_contents(self::getManifestFilePath()));
}

/**
* Test extends tests generation in a suite
*/
public function testSuiteGenerationWithExtends()
{
$groupName = 'suiteExtends';

$expectedContents = [
'ExtendedTestInSuiteChildTestCest.php'
];

// Generate the Suite
SuiteGenerator::getInstance()->generateSuite($groupName);

// Validate log message and add group name for later deletion
TestLoggingUtil::getInstance()->validateMockLogStatement(
'info',
"suite generated",
['suite' => $groupName, 'relative_path' => "_generated" . DIRECTORY_SEPARATOR . $groupName]
);
self::$TEST_GROUPS[] = $groupName;

// Validate Yaml file updated
$yml = Yaml::parse(file_get_contents(self::CONFIG_YML_FILE));
$this->assertArrayHasKey($groupName, $yml['groups']);

$suiteResultBaseDir = self::GENERATE_RESULT_DIR .
DIRECTORY_SEPARATOR .
$groupName .
DIRECTORY_SEPARATOR;

// Validate tests have been generated
$dirContents = array_diff(scandir($suiteResultBaseDir), ['..', '.']);

foreach ($expectedContents as $expectedFile) {
$this->assertTrue(in_array($expectedFile, $dirContents));
}
}

/**
* revert any changes made to config.yml
* remove _generated directory
Expand Down
15 changes: 15 additions & 0 deletions dev/tests/verification/_suite/functionalSuiteExtends.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<suites xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../src/Magento/FunctionalTestingFramework/Suite/etc/suiteSchema.xsd">
<suite name="suiteExtends">
<include>
<group name="ExtendedTestInSuiteChildTest"/>
</include>
</suite>
</suites>
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function getTestsByGroup($groupName)
foreach ($this->tests as $test) {
/** @var TestObject $test */
if (in_array($groupName, $test->getAnnotationByName('group'))) {
$relevantTests[$test->getName()] = $test;
$relevantTests[$test->getName()] = $this->extendTest($test);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something we can add a verification test for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly. I will look into it.

continue;
}
}
Expand Down