Skip to content

MQE-1151: Extending a skipped test fails to generate the parent before and after actions #189

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
Jul 31, 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
66 changes: 66 additions & 0 deletions dev/tests/verification/Resources/ExtendingSkippedTest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
namespace Magento\AcceptanceTest\_default\Backend;

use Magento\FunctionalTestingFramework\AcceptanceTester;
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
use Magento\FunctionalTestingFramework\DataGenerator\Persist\DataPersistenceHandler;
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore;
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("ChildExtendedTestSkippedParent")
* @group Child
*/
class ExtendingSkippedTestCest
{
/**
* @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::CRITICAL)
* @Features({"TestModule"})
* @Stories({"Child"})
* @Parameter(name = "AcceptanceTester", value="$I")
* @param AcceptanceTester $I
* @return void
* @throws \Exception
*/
public function ExtendingSkippedTest(AcceptanceTester $I)
{
$I->comment("text");
$I->comment("child");
}
}
38 changes: 38 additions & 0 deletions dev/tests/verification/Resources/SkippedTestWithHooks.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
namespace Magento\AcceptanceTest\_default\Backend;

use Magento\FunctionalTestingFramework\AcceptanceTester;
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
use Magento\FunctionalTestingFramework\DataGenerator\Persist\DataPersistenceHandler;
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore;
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("skippedTestWithHooks")
* @Description("")
*/
class SkippedTestWithHooksCest
{
/**
* @Stories({"skippedWithHooks"})
* @Severity(level = SeverityLevel::MINOR)
* @Features({"TestModule"})
* @Parameter(name = "AcceptanceTester", value="$I")
* @param AcceptanceTester $I
* @return void
* @throws \Exception
*/
public function SkippedTestWithHooks(AcceptanceTester $I, \Codeception\Scenario $scenario)
{
$scenario->skip("This test is skipped due to the following issues:\nSkippedValue");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@
<remove keyForRemoval="beforeAmOnPageKey"/>
</before>
</test>

<test name="ChildExtendedTestNoParent" extends="ThisTestDoesNotExist">
<annotations>
<severity value="CRITICAL"/>
Expand All @@ -129,4 +128,34 @@
<remove keyForRemoval="beforeAmOnPageKey"/>
</before>
</test>
<test name="SkippedParent">
<annotations>
<severity value="CRITICAL"/>
<title value="PARENTSKIPPED"/>
<group value="Parent"/>
<features value="Parent"/>
<stories value="Parent"/>
<skip>
<issueId value="NONE"/>
</skip>
</annotations>
<before>
<amOnPage url="/beforeUrl" stepKey="beforeAmOnPageKey"/>
</before>
<after>
<amOnPage url="/afterUrl" stepKey="afterAmOnPageKey"/>
</after>
<comment userInput="text" stepKey="keepMe"/>
<comment userInput="text" stepKey="replaceMe"/>
</test>
<test name="ExtendingSkippedTest" extends="SkippedParent">
<annotations>
<severity value="CRITICAL"/>
<title value="ChildExtendedTestSkippedParent"/>
<group value="Child"/>
<features value="Child"/>
<stories value="Child"/>
</annotations>
<comment userInput="child" stepKey="replaceMe"/>
</test>
</tests>
17 changes: 17 additions & 0 deletions dev/tests/verification/TestModule/Test/SkippedTest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@
</skip>
</annotations>
</test>
<test name="SkippedTestWithHooks">
<annotations>
<stories value="skippedWithHooks"/>
<title value="skippedTestWithHooks"/>
<description value=""/>
<severity value="AVERAGE"/>
<skip>
<issueId value="SkippedValue"/>
</skip>
</annotations>
<before>
<comment userInput="skippedComment" stepKey="beforeComment"/>
</before>
<after>
<comment userInput="skippedComment" stepKey="afterComment"/>
</after>
</test>
<test name="SkippedTestTwoIssues">
<annotations>
<stories value="skippedMultiple"/>
Expand Down
11 changes: 11 additions & 0 deletions dev/tests/verification/Tests/ExtendedGenerationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,15 @@ public function testExtendedTestGenerationNoParent()
{
$this->generateAndCompareTest('ChildExtendedTestNoParent');
}

/**
* Tests extending a skipped test generation.
*
* @throws \Exception
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
*/
public function testExtendingSkippedGeneration()
{
$this->generateAndCompareTest('ExtendingSkippedTest');
}
}
11 changes: 11 additions & 0 deletions dev/tests/verification/Tests/SkippedGenerationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ public function testSkippedGeneration()
$this->generateAndCompareTest('SkippedTest');
}

/**
* Tests skipped test generation does not generate hooks.
*
* @throws \Exception
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
*/
public function testSkippedWithHooksGeneration()
{
$this->generateAndCompareTest('SkippedTestWithHooks');
}

/**
* Tests skipped test with multiple issues generation.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,6 @@ public function getAnnotations()
*/
public function getHooks()
{
// if this test is skipped we do not want any before/after actions to generate as the tests will not run
if ($this->isSkipped()) {
return [];
}
return $this->hooks;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,11 @@ private function assembleTestPhp($testObject)

$className = $testObject->getCodeceptionName();
try {
$hookPhp = $this->generateHooksPhp($testObject->getHooks());
if (!$testObject->isSkipped()) {
$hookPhp = $this->generateHooksPhp($testObject->getHooks());
} else {
$hookPhp = null;
}
$testsPhp = $this->generateTestPhp($testObject);
} catch (TestReferenceException $e) {
throw new TestReferenceException($e->getMessage() . "\n" . $testObject->getFilename());
Expand Down