i fell for mocks again...

Поділитися
Вставка
  • Опубліковано 2 жов 2024
  • 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

КОМЕНТАРІ • 109

  • @walker_0924
    @walker_0924 23 години тому +103

    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

  • @hiyabobb
    @hiyabobb День тому +36

    Mocks - poking holes in reality for short term convenience and hoping things will be close enough.

  • @travisnapier71
    @travisnapier71 День тому +50

    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.

  • @abpdev
    @abpdev День тому +16

    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 3 години тому

      Unit test libraries.
      Integration test binaries.

  • @VanosTurbo
    @VanosTurbo День тому +7

    I like mocking but if its to excessive its usually a indication of bad software design.

  • @zyriab5797
    @zyriab5797 4 години тому +2

    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 :)

  • @Saru-Dono
    @Saru-Dono 22 години тому +4

    If it's 10-20 seconds, I don't care. I'll happily watch it to support the channel

  • @nic122583
    @nic122583 22 години тому +3

    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.

  • @dyto2287
    @dyto2287 День тому +12

    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.

  • @othaviorubim5180
    @othaviorubim5180 22 години тому

    Please, continue to do this kind of videos, i love to learn and open my mind with you everyday. Good stuff.

  • @arthurlodbrock2549
    @arthurlodbrock2549 20 годин тому +3

    Go, PHP, Mocks… What’s next? Ruby?

  • @lengors7327
    @lengors7327 21 годину тому +2

    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 23 години тому +11

    if you do paid sponsors please put an accurate, linear-time-progressing loading bar at the bottom of the video

    • @arcowo
      @arcowo 22 години тому +3

      I think chapters are a better option. Even if the creator doesn't make them, SponsorBlock will mark them anyways.

  • @keyboard_g
    @keyboard_g 23 години тому +1

    Prime's Vim theme is all different shades of purple.

    • @TheVimeagen
      @TheVimeagen  22 години тому +1

      i have a specific theme for zig vs other languages for streaming purposes

    • @_start
      @_start 21 годину тому

      @@TheVimeagen zig deez nutz

  • @turculaurentiu91
    @turculaurentiu91 2 години тому

    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.

  • @slpwrm
    @slpwrm День тому +2

    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

  • @teej_dv
    @teej_dv 12 годин тому +1

    should probably do an ad read for a really cool podcast, called Top Shelf

  • @jay_morelli
    @jay_morelli 7 годин тому +1

    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?)

  • @SaintMyles
    @SaintMyles 20 годин тому +1

    Totally fine with the quick ad reads. do what you gotta do

  • @tagpro77
    @tagpro77 17 годин тому

    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 Годину тому

      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.

  • @himalczyk258
    @himalczyk258 4 години тому

    No ads for UA-cam Premium members, give em the ads!👿

  • @harambeexpress
    @harambeexpress 8 годин тому

    10 second ad reads sound fine. I have some faith you'll do it right.

  • @cag1
    @cag1 6 годин тому

    cool new format! 10 mins, focused, calm.

  • @ByteCurator
    @ByteCurator 12 годин тому

    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.

  • @hotscriptgg
    @hotscriptgg 6 годин тому

    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.

  • @notapplicable7292
    @notapplicable7292 3 години тому

    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.

  • @mattwiej
    @mattwiej 18 годин тому

    Get that bag, wouldn't mind the ads :D

  • @stephenreaves3205
    @stephenreaves3205 День тому +1

    Waiting for prime to find out about testcontainers

  • @Peter-UK-nl6cv
    @Peter-UK-nl6cv День тому +1

    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.

  • @gorlug
    @gorlug 7 годин тому

    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.

  • @ravihlb
    @ravihlb 6 годин тому

    Ads are fine, your content is awesome and I trust you won't make it annoying to watch

  • @VivekYadav-ds8oz
    @VivekYadav-ds8oz 13 годин тому +1

    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.

  • @StephenFunk-t4p
    @StephenFunk-t4p 18 годин тому

    I love mocks, but hidden exceptions (or worse, dynamically typed returns!) make them hard.

  • @FaZeInvite17
    @FaZeInvite17 22 години тому

    Loved the video! I don't mind about the small ads

  • @stefanrares9143
    @stefanrares9143 4 години тому

    No problem with the ads!
    I trust you not to sell out

  • @Filou974
    @Filou974 День тому

    Great video, already use and love Turso, so I don't mind ads personnaly.

  • @ivanheffner2587
    @ivanheffner2587 21 годину тому

    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 20 годин тому +1

      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 19 годин тому

      If you're mocking a lot, you're not testing anything useful.

  • @jamesdeen1210
    @jamesdeen1210 10 годин тому

    Best non-ad ad

  • @johnlovell8299
    @johnlovell8299 16 годин тому

    Mocks are good when you are in early development. SQUEEL LIGHT for the win.

  • @Gandalf_Le_Dev
    @Gandalf_Le_Dev 23 години тому

    Can we get a video on your custom logs ? I love this kind of content, thanks prime

  • @paulmurray3244
    @paulmurray3244 4 години тому

    Go for it, be good to hear what things are catching your attention, and you should earn a dime or two

  • @matiasbpg
    @matiasbpg 15 годин тому

    Mocks for most unit tests means the code is too coupled. Fake data should be enough for the vast majority of the code

  • @dyershov
    @dyershov 21 годину тому +2

    With real server requests, your tests may become non deterministic and tests become flaky.

  • @MrSebLD
    @MrSebLD 17 годин тому

    Mocks in go are best implemented with interfaces

  • @johansmith2840
    @johansmith2840 День тому

    no problem, if it helps you keep going all for it. But will they match Theo's advertisements?

  • @ficolas2
    @ficolas2 День тому

    Go ahead with the turso ads, get the bag
    LGTM

  • @hapaise2924
    @hapaise2924 13 годин тому

    love this and i dont mind an ad but wouldnt prefer it

  • @wesleycoder
    @wesleycoder 20 годин тому

    Ad me up baby! Turso is great and I love to know about their new features.

  • @ssmith99
    @ssmith99 18 годин тому +1

    Ads for stuff you use are great

  • @sirisaac8727
    @sirisaac8727 3 години тому

    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

  • @louislynch1
    @louislynch1 12 годин тому

    don't write mocks, write fakes.

  • @moustafaharoun5141
    @moustafaharoun5141 22 години тому

    Ads are fine I trust you that it would not be something useless.

  • @sub-harmonik
    @sub-harmonik 15 годин тому

    you can't really avoid mocking a database unless you have an environment for that specifically

  • @4bclover
    @4bclover День тому

    do the ad of everything you can think can be REALLY useful.

  • @ProVrakian
    @ProVrakian 19 годин тому +1

    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.

  • @andreaselfving2787
    @andreaselfving2787 21 годину тому

    I use mocks for testing non-happy path.

    • @andreaselfving2787
      @andreaselfving2787 21 годину тому

      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

  • @palharez
    @palharez 4 години тому

    Go ahead. I think good products must have to be shared with everyone

  • @rissmau11
    @rissmau11 21 годину тому +1

    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).

  • @Ross96D
    @Ross96D День тому

    Turso ads would be ads i would watch

  • @OxyniteCasual
    @OxyniteCasual 21 годину тому

    yes adds, i really like your videos and wish i could support you, so adds are great

  • @Ducky39101
    @Ducky39101 22 години тому +1

    I don't know what turso is but get payed if you can

  • @jannikl7
    @jannikl7 19 годин тому

    As long as you make the ads Tim Dillon style, go ahead 😅

  • @brazghost
    @brazghost 23 години тому

    Timeline Summary:
    0:00-0:35: The creator initially felt that mocks were a good way to test complex systems but later realized they can cause issues.
    0:35-1:57: The creator explains how mocks are useful for testing specific functions but can give a false sense of security.
    1:57-4:13: The creator argues that using real data and real systems leads to more accurate results in testing.
    4:13-5:35: The creator compares mocks to documentation, noting both can become outdated or inaccurate over time.
    5:35-6:15: The creator emphasizes the importance of testing assumptions and warns against relying solely on mocks.
    6:15-7:57: The creator shares their approach to testing: using real data and systems, with a mocking library for specific functions.
    7:57-9:06: 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 22 години тому

      Bro summary by some AI tool? Let us know which one?

  • @marcusrehn6915
    @marcusrehn6915 6 годин тому

    Have you considered contract testing?

  • @MiaChillfox
    @MiaChillfox День тому +1

    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.

  • @andrewshirley9240
    @andrewshirley9240 21 годину тому

    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  19 годин тому +1

      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 21 годину тому

    Keep it up! Looks good!

  • @guittoplex
    @guittoplex День тому

    ever heard of test pyramid?

  • @Skaiiur
    @Skaiiur 19 годин тому

    Ads is fine, sir

  • @smrdotgg
    @smrdotgg День тому

    W ads I trust you

  • @spfy
    @spfy 23 години тому

    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  22 години тому +1

      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 21 годину тому

    ADS ADS ADS ADS

  • @hamm8934
    @hamm8934 День тому +2

    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.

  • @keyboard_g
    @keyboard_g 23 години тому

    You checking in your state of the world database into Git? If your service is large enough to require Postgres?

    • @TheVimeagen
      @TheVimeagen  22 години тому +1

      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 21 годину тому

      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.

  • @Lado93
    @Lado93 18 годин тому

    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 23 години тому

    turso ads are ok ads

  • @balintfazekas9696
    @balintfazekas9696 23 години тому

    4:37 - Same thing John Carmack said about print debugging and actual debuggers: ua-cam.com/video/rhUwOBg4TyM/v-deo.htmlsi=E5YspS3S7hK-bDmm&t=277

  • @chuckleezy
    @chuckleezy Годину тому

    does anyone know what theme he is using?

  • @alanis4AL
    @alanis4AL 8 годин тому

    Do ads

  • @ishaankapoor933
    @ishaankapoor933 День тому +1

    1st