I'm new to testing in Laravel (Watch me learn)

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 พ.ย. 2024

ความคิดเห็น •

  • @codewithsub5083
    @codewithsub5083 3 หลายเดือนก่อน +7

    It's been 8 years since I started working with Laravel, leading a team of senior developers and now running my own SAAS business built on Laravel. Still, when I see a new Laravel-related video, especially from its maintainers, it gives me a next level of satisfaction.
    Thank you so much, Laravel team, for building and maintaining this amazing framework.
    ❤❤❤❤❤❤❤❤❤❤❤

    • @LaravelPHP
      @LaravelPHP  3 หลายเดือนก่อน +1

      That's an incredible journey. Thank you for sharing. :) Keep up the great work!
      -Josh

  • @CharlesMartel829
    @CharlesMartel829 3 หลายเดือนก่อน +10

    I've got a master in applied statistics and one of the first things a professor said in my first statistics class when another student asked him about a simple significance test was "I don't know".

    • @LaravelPHP
      @LaravelPHP  3 หลายเดือนก่อน +3

      Sounds like a professor I would have loved! :)
      -Josh

    • @Xewl
      @Xewl 3 หลายเดือนก่อน +3

      A teacher to acknowledge that he doesn't know something, is better than one that doesn't (:

  • @JonBrookes
    @JonBrookes 3 หลายเดือนก่อน +1

    thanks for this Josh, not nearly enough is said of testing and seeing your fresh take on Laravel testing is most welcome. Your approach is a good one in that your helping all to use tests and in a way that is encouraging and uncomplicated, so we all need to do tests now 🚀🚀

    • @LaravelPHP
      @LaravelPHP  2 หลายเดือนก่อน +1

      So glad that this was helpful Jon. I've already written more tests since this video! ☺️
      -Josh

  • @ReyhanJoseph
    @ReyhanJoseph 3 หลายเดือนก่อน

    i started watching you for laravel but you saying you never tested in Laravel just makes me more intrigued lol to learn so you got me hooked lol

    • @LaravelPHP
      @LaravelPHP  3 หลายเดือนก่อน +1

      I'll take it. 😂
      -Josh

  • @ronaldngarombo1026
    @ronaldngarombo1026 3 หลายเดือนก่อน +1

    I started learning testing yesterday, from the Laravel docs 😁

    • @LaravelPHP
      @LaravelPHP  3 หลายเดือนก่อน

      Hey me too! :)
      -Josh

  • @mike-2342
    @mike-2342 3 หลายเดือนก่อน

    This is really good. Too often our industry just feigns competence in literally everything.

    • @LaravelPHP
      @LaravelPHP  3 หลายเดือนก่อน

      I'm glad you agree. I think there's a lot we all can learn when we realize that there's SO MUCH to learn. :)
      -Josh

  • @dajoeberlei
    @dajoeberlei 3 หลายเดือนก่อน +4

    I love testing. Allthough im often falling into the pithole of "i quickly need to write that feature, ill test it later" cause im kinda in the need of delivering fast often. I think even with taking the extra time of writing the tests it probably often would even save time but i dont actually know. Do you guys know that mindset and have you broken that cycle? And if so how? I find myself very often I a bug situation later on where i think "If i only had written a test back then, that wouldn't have happen"

    • @LaravelPHP
      @LaravelPHP  3 หลายเดือนก่อน +3

      Hopefully others can chime in, but I can say as someone who now wants to write tests for features I have written in the past, I think testing is a great way to get you to stop and think about what a particular page/feature/components needs to be able to do before you even test it on the page.
      I think that's going to be my approach from now on:
      - Write the Livewire logic
      - Write a test
      - Write the front-end
      - Test it from the UI
      But... I'm still learning. :)
      -Josh

    • @Pekz00r
      @Pekz00r 3 หลายเดือนก่อน

      Yes, that heppens to me a lot as well. I also really don't like the TDD approach because it feels so backwards and you often don't know exactly how the solution should work before you start.
      I find that unit tests are usually not really needed and can often be a waste of time. I prefer feature tests and E2E testing in most cases. Unit tests are great for some critical parts of the application where it needs to be exactly right. For example price calculations or payment flows.

    • @darylphuah
      @darylphuah 3 หลายเดือนก่อน +1

      If you fully write the feature, you'll never write the test. For one, you've "done" your work, so a test now feels like a waste of effort. Secondly, because you already implemented the code, you know too much and will end up polluting your test with implementation details that it shouldn't know about; making it a bad test.
      you need to go somewhat 50-50.
      1. Write the first few high level abstractions of the code and its flow. You're not writing any implementation details yet, just what input/outputs and functions are being called.
      2. Identify the critical paths you need to test for in the code (You might not need to test everything)
      3. Write the tests, they should all fail because none of the code for it actually exists yet.
      4. Start writing the code, starting from unit test level up to the feature level.
      This way is far more natural than the strict TDD approach. You've already mapped out the shape/flow of your code, then now you're using tests to ensure that when you implement it, you don't miss or f`k up anything else.

  • @stefanilic4178
    @stefanilic4178 3 หลายเดือนก่อน

    I love your videos, it's always so interesting. Keep it up! :)
    Can you tell which theme and icon theme you are using in vs code?

    • @jalancarimakan507
      @jalancarimakan507 3 หลายเดือนก่อน

      i second this!

    • @LaravelPHP
      @LaravelPHP  3 หลายเดือนก่อน +1

      Thank you for the support! :) This is the Catppuccin Frappe theme and icon theme in VS Code.
      -Josh

  • @jebiboy
    @jebiboy 3 หลายเดือนก่อน

    I'm also new to phpunit test. If you're going to do some refactoring from your old module, will you just modify your old feature test or create a new feature test and delete the old feature test?

    • @LaravelPHP
      @LaravelPHP  2 หลายเดือนก่อน

      I think you can just modify your old feature test. But it might be helpful to have them up side by side since that way you know one works. :)
      -Josh

  • @astroshah8378
    @astroshah8378 3 หลายเดือนก่อน

    Which code editor is it? Looks lot simpler to be VS code

    • @LaravelPHP
      @LaravelPHP  3 หลายเดือนก่อน

      This IS actually VS Code. :) I have a video on my personal channel of how I set it up and some of the configuration.
      -Josh

  • @dominikbetlej7114
    @dominikbetlej7114 3 หลายเดือนก่อน

    Nicee! Thx!

    • @LaravelPHP
      @LaravelPHP  3 หลายเดือนก่อน +1

      Thanks for learning with me. :)
      -Josh

  • @compton8301
    @compton8301 3 หลายเดือนก่อน

    Thanks

    • @LaravelPHP
      @LaravelPHP  3 หลายเดือนก่อน

      Thanks for watching. :)
      -Josh

  • @CaimAstraea
    @CaimAstraea 3 หลายเดือนก่อน

    I tried to apply testing also but seems I have to fight the framework to make tests like other teams in my company do :(
    They're pretty much mocking every every thing in the framework from model , eloquent , the query builder etc. Not sure if these tests are correct but feels like a pain in the arse to write tests like this. Sure you can also make a test sqlite but I feel this is not the correct way to "unit test" ... I dove down deep the rabbit hole and things got very very academical and complex to the point I gave up. Apparently you can do something like a repository pattern and build on top of the laravel model and that makes it easier to unit test but I have no idea how. Every tutorial or article barely scratches the surface of this. I need a concrete actual good practice example which I couldn't find for the past 2-3 years.

  • @rafamorawiec
    @rafamorawiec 3 หลายเดือนก่อน

    I always thinking about every possible scenario to testing and I never can say "it's enough" and it ends with "ok, i'lll do tests later" (yeah, sure...) :(

    • @LaravelPHP
      @LaravelPHP  3 หลายเดือนก่อน +1

      See, my previous thoughts were always along the lines of, "It's just me so I don't need to do them. :)" Boy was I wrong. Testing could have saved me tons of time in some scenarios.
      -Josh

  • @codewithsub5083
    @codewithsub5083 3 หลายเดือนก่อน +1

    Can you please share your vacode config?
    Theme
    Font
    Icon theme

    • @LaravelPHP
      @LaravelPHP  3 หลายเดือนก่อน

      This is the Catppuccin Frappe theme and Icon theme. And then Dank Mono for the font. :)
      -Josh

    • @codewithsub5083
      @codewithsub5083 3 หลายเดือนก่อน

      ​@@LaravelPHPthank you so much ❤

  • @ricko13
    @ricko13 3 หลายเดือนก่อน

    brb 9:40

  • @kennethlau8108
    @kennethlau8108 3 หลายเดือนก่อน

    Second

    • @LaravelPHP
      @LaravelPHP  3 หลายเดือนก่อน +1

      👋 Glad to have you here to watch the testing newbie. ;D
      -Josh

  • @fahnleindieselschweif5022
    @fahnleindieselschweif5022 3 หลายเดือนก่อน +1

    Fun fact: Pest is the german word for plague. Maybe testing is just that?

    • @LaravelPHP
      @LaravelPHP  3 หลายเดือนก่อน +1

      Uh oh. 👀
      -Josh

    • @Pekz00r
      @Pekz00r 3 หลายเดือนก่อน

      Yes, same in Swedish. It is pretty weird.

    • @Xewl
      @Xewl 3 หลายเดือนก่อน

      It's a play on Jest (the testing framework for JavaScript), but for PHP. "PHP Jest" -> Pest PHP, Pest.
      OfferZen made a video about it, feat Nuno himself: th-cam.com/video/TdtJluPnl6E/w-d-xo.html

  • @mr.mike678
    @mr.mike678 3 หลายเดือนก่อน +1

    Real men test in production

    • @LaravelPHP
      @LaravelPHP  3 หลายเดือนก่อน +1

      Not me anymore. 😁
      -Josh

  • @giropa
    @giropa 3 หลายเดือนก่อน

    Clients don't want to pay extra for testing; it's usually better to wait for the error to appear.

    • @Pekz00r
      @Pekz00r 3 หลายเดือนก่อน +2

      They prefer errors in production and developers spending even more time with manual testing?
      The clients are not always right, especially not in our field. As the expert you need to tell them what is best.

    • @Xewl
      @Xewl 3 หลายเดือนก่อน

      I agree with @@Pekz00r here.
      It's your choice, not theirs. It's your value that you can give to them. If they don't want that value, you have to make sure they understand the higher possibility of future follow-ups and (far) more costs to come when it ultimately fails. It's not only a fail-save for you, but also for them.

    • @andyhinkle
      @andyhinkle 3 หลายเดือนก่อน +5

      Disagree. It might seem cost-effective to wait for errors to appear, this can lead to larger issues down the line, such as unexpected downtime, loss of data, or compromised security.

    • @LaravelPHP
      @LaravelPHP  3 หลายเดือนก่อน +1

      I think in addition to what has been mentioned above, once a team has a flow for testing and creating features, you can build features faster too which the client is ALL for. :)
      -Josh

    • @Cronay
      @Cronay 3 หลายเดือนก่อน +1

      I would never mention tests to clients, either they hire me because they trust me to deliver a good project or not. If they explicitly state I'm not allowed to write tests, I'm not to be hired. Testing saves me time and doing TDD doesn't drain my brain as much with complex logic as when I'm not writing any tests. It's a safety net I'm building for myself to not introduce bugs when changing code later. Currently maintaining a code base and each day a failing tests saves me from introducing new bugs and unwanted behaviour when working on some new requirements.

  • @ryanp56
    @ryanp56 3 หลายเดือนก่อน

    First

    • @LaravelPHP
      @LaravelPHP  3 หลายเดือนก่อน +1

      👋 :)
      -Josh