PEST in Laravel: Worth Switching from PHPUnit?

Поделиться
HTML-код
  • Опубликовано: 29 сен 2024
  • Let's talk about PEST: a tool for automated testing that grew in popularity. I will show you my example, and discuss the potential future of the tool.
    Links mentioned in the video:
    - PEST Official Homepage: pestphp.com/
    - Nuno Maduro: Using PEST in Laravel nunomaduro.com...
    - Main questions and arguments against Pest as the default Laravel testing tool github.com/pes...
    - PR [8.x] Use Pest as the default testing framework github.com/lar...
    - Freek van der Herten: Converting an existing PHPUnit testsuite to Pest • Converting an existing...
    - Laravel Shift: Pest Converter laravelshift.c...
    - My weekly Laravel newsletter: laraveldaily.c...
    - - - - -
    Support the channel by checking out our products:
    - Enroll in my Laravel courses: laraveldaily.t...
    - Try our Laravel QuickAdminPanel: bit.ly/quickad...
    - Purchase my Livewire Kit: livewirekit.com
    - View Laravel Code Examples: laravelexample...
    - Subscribe to my weekly newsletter: bit.ly/laravel-...

Комментарии • 40

  • @bagwaa9948
    @bagwaa9948 2 года назад +24

    I prefer phpunit as its more of a standard at this point, I never understood this obsession to make PHP files smaller, I understand making it more readable and SRP etc, but shaving 40 lines off a test file seems redundant to me. Also, this just feels like we want to use a "jest-like api" in PHP.
    I would argue that Pest is no more readable than standard well written phpunit tests. Also, pest has these extra plugins for stuff that I would just forget. I think it hinges on the team your work within, most of the time the testing framework is already established and the migration to Pest is not really worth the "upgrade" for developer time and cost.

  • @jdlien81
    @jdlien81 2 года назад +4

    I’ve been learning unit testing with Pest and so far, it seems like a nice syntax. I had a feeling it may become the Laravel default some day because it seems much nicer to use but maybe I was overly optimistic about that.

  • @gdogmalone
    @gdogmalone 2 года назад +16

    I love the look and feel of it, but like anything new, I need to understand it’s long term viability and whether it’d be adopted en masse before jumping aboard.

  • @KristherLouisVidal
    @KristherLouisVidal 2 года назад +6

    Its like it was pattern from most JavaScript testing framework. So if you are an OOP guy you’ll gonna hate it. But if you are from JS ecosystem, you will love it.

  • @alexaverkiyev9099
    @alexaverkiyev9099 2 года назад +7

    It's fancy looking but I bet you bump into many things which take a lot of time to figure out.
    Pretty young as you mentioned, it still needs some time. I'm good with PHPUnit, I don't bother writing more lines of code, since I know what I'm doing.
    On the other hand PHPUnit works with classes, therefore it's easier to write contract tests (where you include traits with tests). Not sure if it is easy with Pest.
    And let's be honest, PHPUnit is not bad, it's something what was designed over years. I don't think many would switch to something else that easy.

  • @Thotsuya
    @Thotsuya 2 года назад +6

    I have tried PEST, I like it, but like you mention, I also can't switch from PHPUnit because I think its more standard, and that's the way us laravel / php developers are used to. Maybe in the future it will convice me, who knows, humans are always unwilling to change.

  • @ReveanceFX
    @ReveanceFX 6 месяцев назад +1

    If anything is naming its functions so that calling it spells out a sentence in its entirety, it should be actively avoided

  • @dev22221
    @dev22221 2 года назад +4

    i don't like pest structure because for all php file i see class on the top of the page which pest don't use (maybe i'm deeply into object oriented style)

  • @rtothec1234
    @rtothec1234 Год назад +1

    The describe driven syntax is nice but it is syntactical sugar in the spirit of other BDD test frameworks like Rspec and cucumber.
    The traditional xUnit style of testing framework (which includes PHPUnit) is just fine and its XML reporting output more compatible with build tools like Jenkins.
    As long as you have unit tests in some way or another you are doing better than most people.
    But if you have a lot invested in PHPUnit then don’t feel pressured to switch. You are doing just fine.

  • @iCodeArtisan
    @iCodeArtisan 2 года назад +2

    Seems inspired by jest (for javascript)👌

  • @winkbrace
    @winkbrace 2 года назад +2

    I really don't like the lambda-function style of pest, so I'll actively try to avoid using it. I liked phpspec better, but in the end it's even better if everyone uses the same tool for testing.

  • @plpGTR
    @plpGTR 2 года назад +1

    Anyone here doing Test Driven Development using PEST and used PHP Unit before and can share some experiences?

  • @erichansen9669
    @erichansen9669 2 года назад +4

    I think the arguments against such as "not mature enough" or "not a big enough ecosystem" are horrible markers. I'm not sure how people expect anything to grow if people don't adapt to it.
    I think it' a good thing for Laravel to at least have native support for Pest, but for anything to grow and mature there needs to be users. I like the more simplistic test writing Pest offers, and it doesn't break the flow of PHPUnit testing since you can still use traits and such.
    A much more important metric, and is more personal, would be the amount of time it would take to convert the current code base over if one were to fully commit to Pest.

  • @aurawindsurfing
    @aurawindsurfing 2 года назад +1

    I agree with some of the arguments however if you consider Tailwind. I remember exactly the same arguments vs Bootstrap. Where is Bootstrap now? Another argument about need to dig to figure out the error. If its based on PHPUnit then clearly the error will come from the Unit itself, so whats the problem? I think people have to open minded and actually try it before dismissing it. Think of it this way. Is it better to write Pest or no tests at all? It is doing lots of good to the ecosystem and should not be dismissed just like that IMHO. Thanks!

  • @GergelyCsermely
    @GergelyCsermely 2 года назад +1

    Yes You are right Keep the basic Laravel. Next could be that Pest will be shortened from somebody :) to 74 lines

  • @thisisthelogic
    @thisisthelogic 2 года назад +1

    It looks like cypress or jest syntax

  • @nikolicvladimir
    @nikolicvladimir 2 года назад

    So to get 40 lines less in test file, arguably more readable, you need to learn new 'thing', and import 2 more third party packages. It looks ok, but i am failing to see advantage over built in larvel testing

  • @mahaali6947
    @mahaali6947 2 года назад

    Hi .. Thanks to all services and expansions you really offer me in my work .. My inquiry regarding you can work a cycle on how to register the user's voice immediately and store it in the database ??

  • @miratechsolutions5777
    @miratechsolutions5777 Год назад

    I like your effort in this video and your conclusion either!

  • @avidian4759
    @avidian4759 2 года назад +4

    If it's a solo project, I will use Pest since I'm the only developer. I will learn a new tool and it's going to give me productivity gains.
    But if it's with a team of developers with the future in mind, maybe not yet for now.
    I have high hopes for Pest and PHPUnit in the future. I really like it.

    • @avidian4759
      @avidian4759 2 года назад +2

      UPDATE January 1, 2022
      I tried it on a new project that I'm working on.
      It's almost the same as PHPUnit. Nothing changed except that the lines of code are fewer. There are no extra benefits.
      I still like it though. The test suite has way less code and easier to read.

  • @artavazdavagyan
    @artavazdavagyan 2 года назад

    similar to jest syntax

  • @divineperspicaciousness
    @divineperspicaciousness 2 года назад

    Feel like a dinosaur when the kids talk about unit testing... I have never used it commercially? Can someone explain the necessity in laymen's? Is it just to check your app isn't broken by some outside event? Then you cronjob tests for automatic alerting on break?

    • @LaravelDaily
      @LaravelDaily  2 года назад

      In short, yes. It's like hiring a robot to test if your system still works, every time you make some change or refactor some code.
      Otherwise, if you don't have that "robot" working for you, you need to test everything manually, including the old features that may have been affected by new code.

  • @ThePhilosoft
    @ThePhilosoft 2 года назад

    On word: gherkin

  • @digitaluniverse9826
    @digitaluniverse9826 2 года назад

    Hi Mr povilas. A quick question please , is there any online resource or a course that you recommend to master phpunit? I haven't been able to find a comprehensive single series.

    • @LaravelDaily
      @LaravelDaily  2 года назад +1

      This one is good: spatie.be/products/testing-laravel
      Also: laracasts.com/topics/phpunit
      I will update my course when Laravel 9 comes out.

    • @digitaluniverse9826
      @digitaluniverse9826 2 года назад

      Thank you very much for the quick response.

  • @jedmalveda
    @jedmalveda 2 года назад

    Do you have a course for unit testing in laravel?

    • @LaravelDaily
      @LaravelDaily  2 года назад +2

      I do but it's a bit outdated, from 2019: laraveldaily.teachable.com/p/laravel-phpunit-testing-for-beginners
      Planning to update it when Laravel 9 comes out.
      Meanwhile I can recommend a new course from Spatie: spatie.be/products/testing-laravel

    • @jedmalveda
      @jedmalveda 2 года назад

      @@LaravelDaily Thank you. Looking forward for it.

  • @adesanoyesamson668
    @adesanoyesamson668 2 года назад +1

    I just start writing tests in PHP. Pest has companies backing it, Thanks for sharing

  • @ricko13
    @ricko13 2 года назад

    I don't even use PHPUnit :(

    • @LaravelDaily
      @LaravelDaily  2 года назад

      Why?

    • @ricko13
      @ricko13 2 года назад

      @@LaravelDaily because it consumes time that can be used for other things, and thank God I've never been in a situation where I needed it

    • @alexaverkiyev9099
      @alexaverkiyev9099 2 года назад +5

      @@ricko13 Don't worry, when you start writing and supporting big complex projects, you will start using PHPUnit and you will thank its creators for its existance :)

    • @richardtaylor8790
      @richardtaylor8790 2 года назад +2

      I used to be in the same boat. And for small projects I'm still probably light on tests. However, you will see the benefit on larger projects with paid users and possibly other devs. Basically, anything you really care about ;) When you make a change or addition, trust me, you will be thankful to know that it hasn't broken something unexpected that will come back to haunt you! Or that you haven't broken someone else's code. It's SO much easier to simply run tests in a few seconds, rather than manually test (sometimes long) processes. And manual tests may not pick up all the unexpected stuff. This is just scratching the surface. But there are so many benefits to automated testing. It's also SO simple generally, that there's really no reason not to do it given the benefits.

    • @lukmauu
      @lukmauu 2 года назад

      I have a small scheduler project, and do to complex of events timeframes overlapping each I would not catch some erros without PhoUnit. You going to write more code but in a very fast pass and it will guarantee the outcome