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

  Рет қаралды 10,711

Laravel

Laravel

Күн бұрын

Пікірлер: 51
@codewithsub5083
@codewithsub5083 4 ай бұрын
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 4 ай бұрын
That's an incredible journey. Thank you for sharing. :) Keep up the great work! -Josh
@CharlesMartel829
@CharlesMartel829 4 ай бұрын
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 4 ай бұрын
Sounds like a professor I would have loved! :) -Josh
@Xewl
@Xewl 4 ай бұрын
A teacher to acknowledge that he doesn't know something, is better than one that doesn't (:
@JonBrookes
@JonBrookes 3 ай бұрын
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 3 ай бұрын
So glad that this was helpful Jon. I've already written more tests since this video! ☺️ -Josh
@ReyhanJoseph
@ReyhanJoseph 4 ай бұрын
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 4 ай бұрын
I'll take it. 😂 -Josh
@ronaldngarombo1026
@ronaldngarombo1026 4 ай бұрын
I started learning testing yesterday, from the Laravel docs 😁
@LaravelPHP
@LaravelPHP 4 ай бұрын
Hey me too! :) -Josh
@mike-2342
@mike-2342 4 ай бұрын
This is really good. Too often our industry just feigns competence in literally everything.
@LaravelPHP
@LaravelPHP 4 ай бұрын
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 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 4 ай бұрын
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 4 ай бұрын
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 4 ай бұрын
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.
@CaimAstraea
@CaimAstraea 4 ай бұрын
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.
@jebiboy
@jebiboy 4 ай бұрын
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 3 ай бұрын
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
@stefanilic4178
@stefanilic4178 4 ай бұрын
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 4 ай бұрын
i second this!
@LaravelPHP
@LaravelPHP 4 ай бұрын
Thank you for the support! :) This is the Catppuccin Frappe theme and icon theme in VS Code. -Josh
@astroshah8378
@astroshah8378 4 ай бұрын
Which code editor is it? Looks lot simpler to be VS code
@LaravelPHP
@LaravelPHP 4 ай бұрын
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
@compton8301
@compton8301 4 ай бұрын
Thanks
@LaravelPHP
@LaravelPHP 4 ай бұрын
Thanks for watching. :) -Josh
@codewithsub5083
@codewithsub5083 4 ай бұрын
Can you please share your vacode config? Theme Font Icon theme
@LaravelPHP
@LaravelPHP 4 ай бұрын
This is the Catppuccin Frappe theme and Icon theme. And then Dank Mono for the font. :) -Josh
@codewithsub5083
@codewithsub5083 4 ай бұрын
​@@LaravelPHPthank you so much ❤
@rafamorawiec
@rafamorawiec 4 ай бұрын
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 4 ай бұрын
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
@dominikbetlej7114
@dominikbetlej7114 4 ай бұрын
Nicee! Thx!
@LaravelPHP
@LaravelPHP 4 ай бұрын
Thanks for learning with me. :) -Josh
@ricko13
@ricko13 4 ай бұрын
brb 9:40
@kennethlau8108
@kennethlau8108 4 ай бұрын
Second
@LaravelPHP
@LaravelPHP 4 ай бұрын
👋 Glad to have you here to watch the testing newbie. ;D -Josh
@fahnleindieselschweif5022
@fahnleindieselschweif5022 4 ай бұрын
Fun fact: Pest is the german word for plague. Maybe testing is just that?
@LaravelPHP
@LaravelPHP 4 ай бұрын
Uh oh. 👀 -Josh
@Pekz00r
@Pekz00r 4 ай бұрын
Yes, same in Swedish. It is pretty weird.
@Xewl
@Xewl 4 ай бұрын
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: kzbin.info/www/bejne/ipXXe5-rhdOfbKc
@mr.mike678
@mr.mike678 4 ай бұрын
Real men test in production
@LaravelPHP
@LaravelPHP 4 ай бұрын
Not me anymore. 😁 -Josh
@giropa
@giropa 4 ай бұрын
Clients don't want to pay extra for testing; it's usually better to wait for the error to appear.
@Pekz00r
@Pekz00r 4 ай бұрын
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 4 ай бұрын
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 4 ай бұрын
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 4 ай бұрын
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 4 ай бұрын
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 4 ай бұрын
First
@LaravelPHP
@LaravelPHP 4 ай бұрын
👋 :) -Josh
Правильный подход к детям
00:18
Beatrise
Рет қаралды 2,2 МЛН
Lazy days…
00:24
Anwar Jibawi
Рет қаралды 8 МЛН
How many people are in the changing room? #devil #lilith #funny #shorts
00:39
Laravel + Livewire todo app (and so much more)
16:41
Aaron Francis
Рет қаралды 51 М.
PEST тесты в Laravel. Обзор фреймворка для написания тестов
18:18
Просто о Web Development. CutCode
Рет қаралды 2,4 М.
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 107 МЛН
NextJS and Laravel Can Be Friends
23:54
Laravel
Рет қаралды 29 М.
Why is everyone LYING?
7:56
NeetCodeIO
Рет қаралды 364 М.
Write awesome tests by Jeroen Mols
46:26
Devoxx
Рет қаралды 20 М.
Vim Tips I Wish I Knew Earlier
23:00
Sebastian Daschner
Рет қаралды 80 М.
Laravel First Impressions From A JavaScript Dev
21:08
adamdotdev
Рет қаралды 139 М.
Правильный подход к детям
00:18
Beatrise
Рет қаралды 2,2 МЛН