Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

HTML Report: Successful Tests Can Be Incorrectly Coloured Red #4

Closed
@Tenzian

Description

@Tenzian

In the HTML report, when using a Cest with a dataprovider, if one of the tests fails then all subsequent tests using that dataprovider are coloured in red even if they pass.

Example

Cest

<?php
namespace { # global namespace

    class FailsCest
    {

       /**
        * @dataprovider pageProvider
        */
        public function withProvider(AcceptanceTester $I, \Codeception\Example $example)
        {
            $I->amOnPage($example['url']);
            $I->seeInTitle($example['title']);
        }

        public function failedWithoutProvider(AcceptanceTester $I)
        {
            $I->amOnPage("http://www.bbc.co.uk");
            $I->see('rumplestiltskin', 'h1');
        }

        public function passedWithoutProvider(AcceptanceTester $I)
        {
            $I->amOnPage("http://www.bbc.co.uk");
            $I->see('BBC Homepage', 'h1');
        }

        public function failedAssert(AcceptanceTester $I)
        {
            $I->assertEquals(true, false);
        }

        public function passedAssert(AcceptanceTester $I)
        {
            $I->assertEquals(true, true);
        }

        /**
         * @return array
         */
        protected function pageProvider()
        {
            return [
                [
                    'url'   => "http://www.bbc.co.uk",
                    'title' => "BBC - Home"
                ],
                [
                    'url'   => "http://codeception.com",
                    'title' => "Zebra"
                ],
                [
                    'url'   => "http://www.php.net",
                    'title' => "PHP: Hypertext Preprocessor"
                ],
                [
                    'url'   => "http://www.google.com",
                    'title' => "Google"
                ],

            ];
        }
    }
}

CLI

$ codecept run acceptance --html
Codeception PHP Testing Framework v2.4.1
Powered by PHPUnit 7.0.2 by Sebastian Bergmann and contributors.

Acceptance Tests (8) ---------------------------------------------------------------------------------------------------------------
✔ FailsCest: With provider | "http://www.bbc.co.uk","BBC - Home" (0.56s)
✖ FailsCest: With provider | "http://codeception.com","Zebra" (1.25s)
✔ FailsCest: With provider | "http://www.php.net","PHP: Hypertext Preprocessor" (0.15s)
✔ FailsCest: With provider | "http://www.google.com","Google" (0.14s)
✖ FailsCest: Failed without provider (0.45s)
✔ FailsCest: Passed without provider (0.55s)
✖ FailsCest: Failed assert (0.00s)
✔ FailsCest: Passed assert (0.00s)
------------------------------------------------------------------------------------------------------------------------------------


Time: 3.24 seconds, Memory: 12.00MB

There were 3 failures:

---------
1) FailsCest: With provider | "http://codeception.com","Zebra"
 Test  tests/acceptance/FailsCest.php:withProvider
 Step  See in title "Zebra"
 Fail  page title contains Zebra
Failed asserting that '\n
        \n
        Codeception\n
        \n
    ' contains "Zebra".

Scenario Steps:

 2. $I->seeInTitle("Zebra") at tests/acceptance/FailsCest.php:13
 1. $I->amOnPage("http://codeception.com") at tests/acceptance/FailsCest.php:12


---------
2) FailsCest: Failed without provider
 Test  tests/acceptance/FailsCest.php:failedWithoutProvider
 Step  See "rumplestiltskin","h1"
 Fail  Failed asserting that any element by 'h1' on page / 
+ <h1 class="hp-main-heading" id="hp-bbc-homepage-content">BBC Homepage</h1>
contains text 'rumplestiltskin'

Scenario Steps:

 2. $I->see("rumplestiltskin","h1") at tests/acceptance/FailsCest.php:19
 1. $I->amOnPage("http://www.bbc.co.uk") at tests/acceptance/FailsCest.php:18


---------
3) FailsCest: Failed assert
 Test  tests/acceptance/FailsCest.php:failedAssert
 Step  Assert equals true,false
 Fail  Failed asserting that false matches expected true.

Scenario Steps:

 1. $I->assertEquals(true,false) at tests/acceptance/FailsCest.php:30


FAILURES!
Tests: 8, Assertions: 8, Failures: 3.
- HTML report generated in file:///Users/Tenz/Repositories/demo/tests/_output/report.html

HTML

screen shot 2018-03-01 at 14 29 32

Expected Results

"With provider" results for http://www.php.net and http://www.google.com should be green.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions