i fell for mocks again...

  Рет қаралды 19,647

TheVimeagen

TheVimeagen

Күн бұрын

LIVE ON TWITCH: / theprimeagen
Become a backend engineer. Its my favorite site
boot.dev/?prom...
This is also the best way to support me is to support yourself becoming a better backend engineer.
Get in on Discord: / discord
Get in on Twitter: / theprimeagen
Got Something For Me to Read or Watch??:
/ theprimeagenreact

Пікірлер: 120
@hiyabobb
@hiyabobb Күн бұрын
Mocks - poking holes in reality for short term convenience and hoping things will be close enough.
@walker_0924
@walker_0924 Күн бұрын
Yeah ads is fine, I trust your integrity enough that ads would probably be a sort of "recommendation" or like "hey take a look at this cool stuff" It helps pay the bills for my favourite creator as well so, do what you do mustache man. Love your content
@Slashx92
@Slashx92 Күн бұрын
second this
@JonathanMorrisMusic
@JonathanMorrisMusic Күн бұрын
Third this
@glitchinLife
@glitchinLife Күн бұрын
Forth deez, oh no this not twitch 😮
@muyewahqomeyour7206
@muyewahqomeyour7206 Күн бұрын
fifth this
@miereza
@miereza Күн бұрын
sixth this
@abpdev
@abpdev Күн бұрын
Mhhh. Unit testing? Mock. Integration tests, do not mock. A pull request or commit should have unit test. I think that’s where mocking is the most useful for me. At the end of the day, you need to throw your product out in the wild in connect it with every service, do it immediately or later. It’s all up to you.
@jonathan2847
@jonathan2847 21 сағат бұрын
Unit test libraries. Integration test binaries.
@youtubeenjoyer1743
@youtubeenjoyer1743 2 сағат бұрын
So you end up with thousands of so-called unit tests that test themselves, and now your program is impossible to refactor without also rewriting thousands of lines of tests just to conform to the refactored code structure. Unit tests are dead code. Write integration tests instead.
@travisnapier71
@travisnapier71 Күн бұрын
I'm loving this new content format. Succinct and informative. Testing is a blind spot for me and I'm appreciative of you sharing your experience with them. Definitely throw in their some ad reads in these videos. I feel you respect your audience enough to make sure that the tech you're promoting is authentic and legit.
@VanosTurbo
@VanosTurbo Күн бұрын
I like mocking but if its to excessive its usually a indication of bad software design.
@Saru-Dono
@Saru-Dono Күн бұрын
If it's 10-20 seconds, I don't care. I'll happily watch it to support the channel
@nic122583
@nic122583 Күн бұрын
I do both types of testing. Unit testing to me is all about documenting my assumptions of the other systems my code needs to talk to. That way, when the integration tests fails, I can match the failure to my assumptions and know how I need to change my code. Also, unit tests are usually the only way I can tests some error states that could come from the other system if the other system doesn't give me a way to simulate that error state.
@tigranrostomyan9231
@tigranrostomyan9231 Күн бұрын
YEAH, exactly
@zyriab5797
@zyriab5797 22 сағат бұрын
I appreciate you making these videos and not only streaming as I don't have time to watch streams. Also the feel is different than in clips. So thanks! Also, I'm cool with the ads, I think you're a man of integrity :)
@dyto2287
@dyto2287 Күн бұрын
Mocks are for unit tests to test specific scenarios on small chunk of code. For integration tests you should use testcontainers not mocks. Usually you would use both for different things. Like testing storage implementation with testcontainer and testing service with mock of your storage.
@Jason-xw2md
@Jason-xw2md 15 сағат бұрын
Love this format, the past few videos on this channel have been super insightful and gotten me to think pretty deeply about the topics you've covered. Also super OK with ads.
@arthurlodbrock2549
@arthurlodbrock2549 Күн бұрын
Go, PHP, Mocks… What’s next? Ruby?
@vhaangol4785
@vhaangol4785 Күн бұрын
Believe in DHH
@othaviorubim5180
@othaviorubim5180 Күн бұрын
Please, continue to do this kind of videos, i love to learn and open my mind with you everyday. Good stuff.
@teej_dv
@teej_dv Күн бұрын
should probably do an ad read for a really cool podcast, called Top Shelf
@harambeexpress
@harambeexpress Күн бұрын
10 second ad reads sound fine. I have some faith you'll do it right.
@slpwrm
@slpwrm Күн бұрын
Its not hard to do similar mocks in other DBs, at work we do the same with postgres, we have a seed file that resets on each test suit, coincidentally the same seeds we use for local development. It works fantastic, I'm amazing to see actual SQL errors show up on the tests, that didn't happen to me before in the "mock everything" mindset
@jay_morelli
@jay_morelli Күн бұрын
Hey prime, thanks for the video! I am 100% with you here 😄 Also, for the ads, please do! You are NOT the person of selling something you don't believe in, so I would definitely be interested in find out more cool stuff (that is what ads are for, right?)
@lengors7327
@lengors7327 Күн бұрын
The usage of mocks in tests, the degree of acceptance and the degree of strength behind the reasoninh to use them, depends on the type of test, imo. For unit tests, mocks can (and probably should) be used and you don't need a very strong reason to do so. Their usage should be easily acceptable, as unit tests test if the code behaves as you expect it to in regards to the assumptions you make about the world. For integration and e2e tests, however, the degree of acceptance for the usage of mocks should be much lower, and only be used in very specific situations (i.e. have a strong reason to do so, larger for e2e tests).
@Sam-cp6so
@Sam-cp6so Күн бұрын
if you do paid sponsors please put an accurate, linear-time-progressing loading bar at the bottom of the video
@arcowo
@arcowo Күн бұрын
I think chapters are a better option. Even if the creator doesn't make them, SponsorBlock will mark them anyways.
@keyboard_g
@keyboard_g Күн бұрын
Prime's Vim theme is all different shades of purple.
@TheVimeagen
@TheVimeagen Күн бұрын
i have a specific theme for zig vs other languages for streaming purposes
@_start
@_start Күн бұрын
@@TheVimeagen zig deez nutz
@streamcyper
@streamcyper 12 сағат бұрын
In a project I've been working on, I made a dummy database handler, that instead of using a database it uses slices and maps for the data. And it has been working great, because in the constructed world I have perfect control over what everything does, I of course use it in combination with end to end tests, but instead of spinning up a full database when I just need to give inputs and outputs to the application, I know what the input should be and I know what I want in return. With that I can easily check that my application work as intended, since I am programing against a defined interface, and once that breaks I know something is wrong. This works because when I made the dummy I did make assumptions on how the world works, and made something that worked with my assumption. I then of course learned that I was very wrong, but that also meant that what I was doing in my application was wrong. So I had to fix my assumption and now both the dummy and the real database works as intended. It will of course break, but that also means that I have been walking away from the original goal and I need to find out why, and either fix it by going back or redefine my goal. But yeah nothing can replace end to end tests....
@youtubeenjoyer1743
@youtubeenjoyer1743 2 сағат бұрын
I don't see how that would work with a properly used relational database, unless your queries are no more complex than 'select * from table;'.
@turculaurentiu91
@turculaurentiu91 20 сағат бұрын
What is even harder than setting up 50 servers, is causing 50 servers to error out in specific way so you can assert the error is handled correctly.
@SaintMyles
@SaintMyles Күн бұрын
Totally fine with the quick ad reads. do what you gotta do
@cag1
@cag1 Күн бұрын
cool new format! 10 mins, focused, calm.
@hotscriptgg
@hotscriptgg Күн бұрын
I use mmock btw. It's so nicely tied to actual code and it enforces to regenerate when you change the interface so it stays fresh. Highly recommend.
@himalczyk258
@himalczyk258 22 сағат бұрын
No ads for KZbin Premium members, give em the ads!👿
@notapplicable7292
@notapplicable7292 21 сағат бұрын
I program in a very different world but our maxim is if we can do it for real we do. Unfortunately this can only go so far and mocks / emulators become essential when you dont have spare hardware to facilitate dev testing.
@ByteCurator
@ByteCurator Күн бұрын
Short, quick ads that focus on pointing out that a cool thing exists are completely fine. The more the ad feels like a sales pitch, the more annoying it gets. That being said, the truth is that I wouldn't quit watching if it was over those boundaries.
@stephenreaves3205
@stephenreaves3205 Күн бұрын
Waiting for prime to find out about testcontainers
@tagpro77
@tagpro77 Күн бұрын
Mock makes total sense for unit tests. It is not testing the behaviour of how a function integrates with something outside, but rather the code written in the function. Removing mocks and setting up the connected services/infra is integration test. Unit test is easy to run and good for quick iteration while developing
@mage3690
@mage3690 19 сағат бұрын
I started really disliking that way back when I was doing silly things like building a math library without minus, divide, or multiply. Because every time I tested my stuff, I'd test it with like 1, 2, and 3, and it would return the expected answers. Then it would just explode somewhere or everywhere along the logic chain when I went to use it for anything useful. Obviously that's skill issues as much as anything else, I shouldn't have only tested the most trivial cases, but it's why I personally don't do mocks.
@youtubeenjoyer1743
@youtubeenjoyer1743 2 сағат бұрын
The code that does IO and deals with IO failures is not worth unit testing; the returns are way too low for comparatively high investment. Extract the logic, and maybe do unit tests for the logic.
@mattwiej
@mattwiej Күн бұрын
Get that bag, wouldn't mind the ads :D
@Peter-UK-nl6cv
@Peter-UK-nl6cv Күн бұрын
Sure, for me ads are mostly annoying if it's for things I'm not interested in so I wouldn't mind turso ad reads at all.
@FaZeInvite17
@FaZeInvite17 Күн бұрын
Loved the video! I don't mind about the small ads
@ravihlb
@ravihlb Күн бұрын
Ads are fine, your content is awesome and I trust you won't make it annoying to watch
@StephenFunk-t4p
@StephenFunk-t4p Күн бұрын
I love mocks, but hidden exceptions (or worse, dynamically typed returns!) make them hard.
@gorlug
@gorlug Күн бұрын
Well, if reality changes, and this might come as a shock: you need to change your mocks. You do it at the same time as you change your code that this mock is for. If you don't need to change your code, then you also don't have you to change your mocks. It's not like you write these mocks once and then never think about them again. They are part of your living code documentation. Btw on the topic of ads: I think they'd be fine here.
@Filou974
@Filou974 Күн бұрын
Great video, already use and love Turso, so I don't mind ads personnaly.
@VivekYadav-ds8oz
@VivekYadav-ds8oz Күн бұрын
10 seconds ad is completely fine. Due to the nature of your viewers being very tech-savvy, I wonder how many of them have SponsorBlock installed and would just skip the promotion anyways.
@stefanrares9143
@stefanrares9143 22 сағат бұрын
No problem with the ads! I trust you not to sell out
@Gandalf_Le_Dev
@Gandalf_Le_Dev Күн бұрын
Can we get a video on your custom logs ? I love this kind of content, thanks prime
@johnlovell8299
@johnlovell8299 Күн бұрын
Mocks are good when you are in early development. SQUEEL LIGHT for the win.
@jamesdeen1210
@jamesdeen1210 Күн бұрын
Best non-ad ad
@paulmurray3244
@paulmurray3244 22 сағат бұрын
Go for it, be good to hear what things are catching your attention, and you should earn a dime or two
@MrSebLD
@MrSebLD Күн бұрын
Mocks in go are best implemented with interfaces
@matiasbpg
@matiasbpg Күн бұрын
Mocks for most unit tests means the code is too coupled. Fake data should be enough for the vast majority of the code
@hapaise2924
@hapaise2924 Күн бұрын
love this and i dont mind an ad but wouldnt prefer it
@wesleycoder
@wesleycoder Күн бұрын
Ad me up baby! Turso is great and I love to know about their new features.
@johansmith2840
@johansmith2840 Күн бұрын
no problem, if it helps you keep going all for it. But will they match Theo's advertisements?
@louislynch1
@louislynch1 Күн бұрын
don't write mocks, write fakes.
@ivanheffner2587
@ivanheffner2587 Күн бұрын
When to mock: when you rely on external third-party services and need to test behavior around it. Mock their interface according to their published API and code to match that API.
@SteveKuznetsov
@SteveKuznetsov Күн бұрын
I find this one hard. You could also write your functional code inside the imperative shell. Once you get the data from their API, write functional(-ish) code that operates over that data. Then, when you test, all you need is static test data. If you exercise the code that's calling their API, you run into the view-of-the-world divergence that Primeagen says here - you're ostensibly testing that your code reaches out to the service correctly and gets the data back correctly, but since it's all mocked out you are getting nothing in terms of test coverage and it's trivial to have an error in your mock mean that your test passes but production code is broken.
@natescode
@natescode Күн бұрын
If you're mocking a lot, you're not testing anything useful.
@31redorange08
@31redorange08 14 сағат бұрын
​​@@natescode Look up "unit testing".
@ssmith99
@ssmith99 Күн бұрын
Ads for stuff you use are great
@ficolas2
@ficolas2 Күн бұрын
Go ahead with the turso ads, get the bag LGTM
@dyershov
@dyershov Күн бұрын
With real server requests, your tests may become non deterministic and tests become flaky.
@sirisaac8727
@sirisaac8727 21 сағат бұрын
I mean this is unit-ish test vs integration test. I do agree with you though, I always prefer the latter approach, I don't see much value from the first iteration. I use mocks only for third party api's and such that I cannot do anything about
@4bclover
@4bclover Күн бұрын
do the ad of everything you can think can be REALLY useful.
@moustafaharoun5141
@moustafaharoun5141 Күн бұрын
Ads are fine I trust you that it would not be something useless.
@rasibn
@rasibn 10 сағат бұрын
Turso is good, go for it. Would like a turorial on their multi tenent db pattern in go maybe ;)
@ProVrakian
@ProVrakian Күн бұрын
If it means money for you, and you stand behind the product, I’m all for it. If you could maybe avoid the whiplash sensation that often comes with ad reads though, that would be nice. If anybody’s going to endorse good products and make the ads enjoyable I would expect it to be you.
@rissmau11
@rissmau11 Күн бұрын
I really love your content and this new format. However I would say (as a mockist) that I would not use mocks here but the real thing. I like mocks for very simple components where call order and inner behaviors does not matter. Your test is too close to an integration test. It knows too much about the intricacies of the game server. Your mock does not constraint call order, which can hide bugs. Hard to say just with what we see but I change the design of GameServer so that it only expose one function that returns a server, whether it's a new one or not. I think it's not MatchMakingServer responsibility to negociate for a server. IMHO by doing this change, your whole code will become much simpler to test (and no more complicated mock with multiple functions to call for this test).
@sub-harmonik
@sub-harmonik Күн бұрын
you can't really avoid mocking a database unless you have an environment for that specifically
@palharez
@palharez 22 сағат бұрын
Go ahead. I think good products must have to be shared with everyone
@Ross96D
@Ross96D Күн бұрын
Turso ads would be ads i would watch
@andreaselfving2787
@andreaselfving2787 Күн бұрын
I use mocks for testing non-happy path.
@andreaselfving2787
@andreaselfving2787 Күн бұрын
And also, mocks must be exactly as the world is. If other function calls are made, the test MUST fail. expect is usually not a cause for failure, but asserts are
@OxyniteCasual
@OxyniteCasual Күн бұрын
yes adds, i really like your videos and wish i could support you, so adds are great
@brazghost
@brazghost Күн бұрын
Timeline Summary: <a href="#" class="seekto" data-time="0">0:00</a>-<a href="#" class="seekto" data-time="35">0:35</a>: The creator initially felt that mocks were a good way to test complex systems but later realized they can cause issues. <a href="#" class="seekto" data-time="35">0:35</a>-<a href="#" class="seekto" data-time="117">1:57</a>: The creator explains how mocks are useful for testing specific functions but can give a false sense of security. <a href="#" class="seekto" data-time="117">1:57</a>-<a href="#" class="seekto" data-time="253">4:13</a>: The creator argues that using real data and real systems leads to more accurate results in testing. <a href="#" class="seekto" data-time="253">4:13</a>-<a href="#" class="seekto" data-time="335">5:35</a>: The creator compares mocks to documentation, noting both can become outdated or inaccurate over time. <a href="#" class="seekto" data-time="335">5:35</a>-<a href="#" class="seekto" data-time="375">6:15</a>: The creator emphasizes the importance of testing assumptions and warns against relying solely on mocks. <a href="#" class="seekto" data-time="375">6:15</a>-<a href="#" class="seekto" data-time="477">7:57</a>: The creator shares their approach to testing: using real data and systems, with a mocking library for specific functions. <a href="#" class="seekto" data-time="477">7:57</a>-<a href="#" class="seekto" data-time="546">9:06</a>: The creator concludes by asking for viewer feedback on seeing short ads for a database service the creator uses. Why does the speaker prefer real-world testing? The speaker prefers real-world testing because it provides more accurate and reliable results compared to mocks, which may lead to false confidence and could become outdated or misleading, like documentation.
@mohitkumar-jv2bx
@mohitkumar-jv2bx Күн бұрын
Bro summary by some AI tool? Let us know which one?
@jannikl7
@jannikl7 Күн бұрын
As long as you make the ads Tim Dillon style, go ahead 😅
@Ducky39101
@Ducky39101 Күн бұрын
I don't know what turso is but get payed if you can
@andrewshirley9240
@andrewshirley9240 Күн бұрын
I understanding testing the "happy case" using integration tests. But testing the error cases is way, WAY easier with mocks. Figuring out exactly what inputs or environment states cause which specific errors, especially if it's some ephemeral error, is impossible. Mocks test the behavior that is independent of "reality," and most well-designed functions have a lot of this kind of independence. Like I don't care how the server determined port 42069 was the best port, but given that it did that, how does this unit handle that? I can test that. It can't test everything, integration tests are still vital, but mocks are great at ensuring you're able to hit all of your branches and have them reasonably smoke-screened.
@TheVimeagen
@TheVimeagen Күн бұрын
this is where simulation testing / tiger style stuff comes into big time play (sim testing be equal to fuzz testing) here is a great example: i have a bug that creeps up at 1 million connections added to my game servers. i would definitely have missed that during regular testing, caught on sim testing
@eugeneponomarov7429
@eugeneponomarov7429 Күн бұрын
Keep it up! Looks good!
@marcusrehn6915
@marcusrehn6915 Күн бұрын
Have you considered contract testing?
@nefthy
@nefthy 15 сағат бұрын
doesn't the database file is my mock, get a bit tedious, when the database schema changes?
@MiaChillfox
@MiaChillfox Күн бұрын
I hate mocks, they are no better than a wet blanket. Over the last few months, I have had to deal with so many bugs that wouldn't have happened if the tests had run against a real system instead of mocks.
@guittoplex
@guittoplex Күн бұрын
ever heard of test pyramid?
@smrdotgg
@smrdotgg Күн бұрын
W ads I trust you
@Skaiiur
@Skaiiur Күн бұрын
Ads is fine, sir
@spfy
@spfy Күн бұрын
Isn't a snapshot of the database ALSO an assumption of the world? How is it any different from writing mocks? Over time, the snapshot you are using in your test is going to diverge more and more from the actual database. Unless you mean to take a snapshot each time you run the test? Then how can you verify the results, if you don't know what the test data actually is?
@TheVimeagen
@TheVimeagen Күн бұрын
this is very good point, but i would argue that the shape of the data is a verifiable item that will cause JSON parse / Table parse issues. thus will cause at the moment of using the issue whereas mocks can / will miss types of errors (what do you do if you get a 504 from a service? lots of people don't plan for this but it does happen rarely) so a db changes (hopefully) less often than the order in which call your service functions and their arguments or their potential return values
@kirillvoloshin2065
@kirillvoloshin2065 Күн бұрын
oh wow, welcome to game dev, I guess :D
@th4tAlbinoGuy
@th4tAlbinoGuy Күн бұрын
ADS ADS ADS ADS
@keyboard_g
@keyboard_g Күн бұрын
You checking in your state of the world database into Git? If your service is large enough to require Postgres?
@TheVimeagen
@TheVimeagen Күн бұрын
sqlite is just a file that can be several kb big if you are storing quite a bit. my auto-scaling game server only needs shapes of servers to be stored and i can hydrate that back pretty easily
@keyboard_g
@keyboard_g Күн бұрын
Yea that makes sense. We have a larger db and how to properly test without mocking datasets has been a mental exercise without burying the team when they just want to make a small change and run tests.
@hamm8934
@hamm8934 Күн бұрын
I would be cautious about ad reads and sponsorships. Make sure you actually really use the company through and through. For example, when you promote kinesis, its clear you fully use their products, so why would anyone care? Do you use Turso this much? Are you an actual supporter of Turso? Obviously there are degrees of support. But people will have different threat levels to sponsorship. Look at Theo and Vercel.
@Lado93
@Lado93 Күн бұрын
But brah end to end testing takes ages. If you would write end to end test for everything that a develop i wouldnt do anything else. Unit test gives me abílity to quickly develop and test my solution and cover my edge cases and you cant do unit test without mocking
@gabrielrock
@gabrielrock Күн бұрын
turso ads are ok ads
@balintfazekas9696
@balintfazekas9696 Күн бұрын
<a href="#" class="seekto" data-time="277">4:37</a> - Same thing John Carmack said about print debugging and actual debuggers: kzbin.info/www/bejne/qJm4qIJ4nJmHr68si=E5YspS3S7hK-bDmm&t=277
@chuckleezy
@chuckleezy 19 сағат бұрын
does anyone know what theme he is using?
@alanis4AL
@alanis4AL Күн бұрын
Do ads
@ishaankapoor933
@ishaankapoor933 Күн бұрын
1st
Novidades da Topics Chat by Tiago Paiva analisadas por um Programador
31:24
Tower Defense: How TCP Packets Work
8:52
TheVimeagen
Рет қаралды 37 М.
Minecraft Creeper Family is back! #minecraft #funny #memes
00:26
Players vs Corner Flags 🤯
00:28
LE FOOT EN VIDÉO
Рет қаралды 81 МЛН
Please Help This Poor Boy 🙏
00:40
Alan Chikin Chow
Рет қаралды 23 МЛН
I Got Cited In The WordPress Lawsuit (+ Prime Too)
13:38
Theo - t3․gg
Рет қаралды 72 М.
How 1 Software Engineer Outperforms 138 - Lichess Case Study
22:28
Tom Delalande
Рет қаралды 107 М.
My Initial Impresson Of Go
12:39
TheVimeagen
Рет қаралды 92 М.
The secret economics of Google Street View
22:34
Phil Edwards
Рет қаралды 590 М.
Interview of Arthur Gretton ML Researcher at Google DeepMind
18:14
ML New Papers
Рет қаралды 2,6 М.
Why Devs Prefer PlayStation
9:47
GameLinked
Рет қаралды 55 М.
I used to hate QR codes. But they're actually genius
35:13
Veritasium
Рет қаралды 3,7 МЛН
The only Cloud services you actually need to know
17:17
NeetCodeIO
Рет қаралды 160 М.
Real 10x Programmers Are SLOW To Write Code
14:51
Thriving Technologist
Рет қаралды 51 М.
Minecraft Creeper Family is back! #minecraft #funny #memes
00:26