Giter Club home page Giter Club logo

Comments (18)

jstolp avatar jstolp commented on May 9, 2024 3

+1 any updates?

from phpunit.

Petah avatar Petah commented on May 9, 2024 2

Any updates?

from phpunit.

nickclasener avatar nickclasener commented on May 9, 2024 2

Is it possible to set this in phpunit.xml?
-edit Never mind

cacheResult="true"
executionOrder="defects,reverse"

from phpunit.

keradus avatar keradus commented on May 9, 2024 1

I'm a bit 0/-1 on that functionality. While implement a fix for sth, it is good to not break anything else.
And if you know which exactly component is problematic and needs fixing, just filter to run tests only for it, it's already possible

from phpunit.

Petah avatar Petah commented on May 9, 2024 1

@GrahamCampbell you should be able to filter on data providers:

Without:

$ ../bin/test.sh --filter "CurrencyRateTest::testNormalizeException"
~/work/project/laravel ~/work/project/laravel
Configuration cache cleared!
    PHPUnit 8.5.8 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.4.7 with Xdebug 2.9.5
Configuration: /Users/petah/work/project/laravel/phpunit.xml
Random seed:   1594163298


CurrencyRateTest testNormalizeException with data set #5.
CurrencyRateTest testNormalizeException with data set #4.
CurrencyRateTest testNormalizeException with data set #1.
CurrencyRateTest testNormalizeException with data set #3.
CurrencyRateTest testNormalizeException with data set #2.
CurrencyRateTest testNormalizeException with data set #0.                                                              6 / 6 (100%)

Time: 1.47 seconds, Memory: 38.00 MB

OK (6 tests, 12 assertions)

With:

$ ../bin/test.sh --filter "CurrencyRateTest::testNormalizeException.*2"
~/work/project/laravel ~/work/project/laravel
Configuration cache cleared!
    PHPUnit 8.5.8 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.4.7 with Xdebug 2.9.5
Configuration: /Users/petah/work/project/laravel/phpunit.xml
Random seed:   1594163303


CurrencyRateTest testNormalizeException with data set #2.                                                                   1 / 1 (100%)

Time: 1.01 seconds, Memory: 34.00 MB

OK (1 test, 2 assertions)

from phpunit.

giorgiosironi avatar giorgiosironi commented on May 9, 2024

Proposal: a command:
phpunit --run-failed
which reads the junit log file defined in phpunit.xml or from the passed --log-junit option.
The presence of the log file is a prerequisite for using the feature, because writing one by default would impact performance.

from phpunit.

sebastianbergmann avatar sebastianbergmann commented on May 9, 2024

This would have to be limited to tests that have no dependency (@depends) in the current architecture of PHPUnit.

from phpunit.

reinholdfuereder avatar reinholdfuereder commented on May 9, 2024

IMHO starting from PHPUnit 7.3, because of #3147, this should be possible via --cache-result --order-by=defect

from phpunit.

epdenouden avatar epdenouden commented on May 9, 2024

@reinholdfuereder Yes! That is exactly what the feature is for.

To help protect against unexpected breakages, you can activate the @depends checker to keep tests in as good an order as possible: --cache-result --order-by=depends,defects

from phpunit.

reinholdfuereder avatar reinholdfuereder commented on May 9, 2024

OK, great!

@sebastianbergmann So maybe this issue can be already resolved/closed as (mostly) fixed? (Although one or the other bug might be still around and documentation might need to be added/updated/completed; but that might be already tracked elsewhere, I guess...)

from phpunit.

epdenouden avatar epdenouden commented on May 9, 2024

@reinholdfuereder The combi of functionality from #3147 + #3092 was explicitly aimed at providing this. I am not familiar with JUnit --run-failed and cannot find it in their docs. If anybody has a link that'd be great.

The only missing bit of functionality I still want myself is to only run failed and not just sorting defects to the front of a normal run. I'd have to implement a --filter based on 'status after the previous run(s)'. Totally up for doing that; will have a look when I'm settled at my new job.

from phpunit.

Petah avatar Petah commented on May 9, 2024

FWIW you can pretty easily write a listener to rerun failed tests:

class OutputListener implements \PHPUnit\Framework\TestListener
{
    private $failures = [];

    public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
    {
        $this->failures[get_class($test)] = true;
    }

    public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
    {
        $this->failures[get_class($test)] = true;
    }

    public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
    {
        $content = 'vendor/bin/phpunit --filter ' . implode('\|', array_keys($this->failures));
        $script = __DIR__ . '/../rerun-failed-tests.sh';
        file_put_contents($script, $content . PHP_EOL);
    }
}

from phpunit.

epdenouden avatar epdenouden commented on May 9, 2024

@keradus
As a software developer
I want to rerun failed tests first THEN all tests
so that I can have both a quick red-green cycle and the safety of full coverage

Sounds like something you'd want? :)

from phpunit.

keradus avatar keradus commented on May 9, 2024

from opening message:

The PHPUnit test runner should be enhanced to read a list of previously failed tests from an XML logfile and run these tests before the other tests.

maybe not with xml, but with --order-by=defects we have this already possible.
imho, nothing left here and this feature request can be closed as done

from phpunit.

epdenouden avatar epdenouden commented on May 9, 2024

Agreed :)

from phpunit.

lindt avatar lindt commented on May 9, 2024

yes, should be solved with --cache-result --order-by=depends,defects.

from phpunit.

GrahamCampbell avatar GrahamCampbell commented on May 9, 2024

And if you know which exactly component is problematic and needs fixing, just filter to run tests only for it, it's already possible

Can't filter on data providers though? I only wanna rerun number 624, and not the other two thousand...

image

from phpunit.

GrahamCampbell avatar GrahamCampbell commented on May 9, 2024

Oh, cool. Thanks @Petah. 🍻

from phpunit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.