How To Write Unit Tests For Existing Python Code // Part 1 of 2

Поділитися
Вставка
  • Опубліковано 29 вер 2024

КОМЕНТАРІ • 211

  • @ArjanCodes
    @ArjanCodes  11 місяців тому

    💡 Get my FREE 7-step guide to help you consistently design great software: arjancodes.com/designguide.

  • @grmancool
    @grmancool 2 роки тому +402

    btw Arjan just wanted to mention that I literally got a job offer with twice my current salary by remembering things from your videos in the technical interview. most probably wouldn't have gotten it without you. thanks so much for what you do!

  • @coldhardwick
    @coldhardwick 2 роки тому

    you an mCoding are some of the most valuable resources I've seen on youtube in a looong time....

  • @Klej0aka0Klej
    @Klej0aka0Klej 2 роки тому +1

    I hope the code quality of tests in part2 will be much better, for example many many cases in here should use fixtures to not repeat code or create classes itself inside every test.

    • @ArjanCodes
      @ArjanCodes  2 роки тому +5

      Yes - I’m covering fixtures in part 2.

  • @sagiziv927
    @sagiziv927 2 роки тому +9

    At 9:49 both tests have the same name, so you only test the second function.
    You can see at 9:55 that only 2 tests run…
    My rule of thumb for naming tests, is to be as explicit as possible. I will write what the test passes as input and what is the expected output.
    Like so: `test_order_with_2_items_returns_correct_total`.

    • @virtualraider
      @virtualraider 2 роки тому +2

      It also helps to add a docstring to explain the rationale behind a test:
      ```
      def test_order_total_single_item():
      "Total should match the amount of 1 item"
      ...
      def test_total_order_multiple_items():
      "Total should be equal to the sum of every individual item"
      ```
      In normal code these docstrings would be redundant, but in test code it pays off to write down what the test is meant to do because we're not going to write tests for the tests 😅

  • @gw032sysint9
    @gw032sysint9 2 роки тому +1

    Can you please suggest what is the right way to put constants (like error msgs, log messages, other strings used)?
    What is the best practice to use constants in python :
    (1) a separate .py file for storing strings
    (2) Enums
    (3) Dictionary
    (4) Named Tuples
    (5) Data classes
    (6) anything else

  • @mikeciul8599
    @mikeciul8599 2 роки тому +52

    9:23 there are two functions called `test_order_total`. Python only sees the second one, and the first one doesn't run. This is a great example of how you can have 100% test coverage and still be missing tests!
    I have my vscode configured to run flake8 and mypy. I make this particular mistake all the time when writing tests, but I get a helpfully annoying red underline under the name of the first duplicated function name.

    • @transatlant1c
      @transatlant1c 2 роки тому +2

      Came here to report the same thing! Nice spot 👏

    • @plato4ek
      @plato4ek 2 роки тому +3

      Actually pytest shows the coverage of 82% for `test_order.py`, which gives a hint. So it's not a 100% coverage.

  • @sillytechy
    @sillytechy 2 роки тому +62

    I ll be Frank, design patterns, unit tests for existing code. You are my mentor. And you put up videos which are useful in a production environment.

  • @michaelamoo1353
    @michaelamoo1353 Місяць тому +3

    This guy is literally the best I've seen on youtube. He talks real python, not just some framework. Even when he's doing FastAPI, a lot of the stuff is hardcore python. Keep u the good job my man

  • @mikeciul8599
    @mikeciul8599 2 роки тому +10

    I'd like to know more about your choice of pytest over unittest. Are there particular factors that lead to a preference, or is it just what's more familiar? I've been working on some projects that mix bits from both pytest and unittest, and it's kind of a mess but I don't know which one to go with. There's things that annoy me about both. :D

  • @chadd_robertson
    @chadd_robertson 2 роки тому +38

    I've been programming for a while using Python, and I'd plateaued quite badly.
    Your videos are fantastic, and they're constantly teaching me something new.
    Thank you!

    • @ArjanCodes
      @ArjanCodes  2 роки тому +2

      Thank you Chadd, glad you like the videos!

  • @Betacak3
    @Betacak3 2 роки тому +48

    In my experience, old code that doesn't have tests is often nearly untestable. I recently rewrote a (very old) program that dealt with databases. The UI and the rest of the code are so interwoven that you can't even let it generate an SQL string without first creating a UI component that's responsible for it. That's why I didn't even bother with it. I just rewrote it from scratch.

  • @daymaker_trading
    @daymaker_trading Рік тому +6

    After 3 hours of pain googling and youtubing, finally only your video made it clear how to run test from "tests" folder and make import work. FINALLY! THANK YOU SO MUCH

    • @ArjanCodes
      @ArjanCodes  Рік тому

      Glad it helped!

    • @M_7844
      @M_7844 4 місяці тому

      Same here. I find it quite complicated to make import work correctly. I would like to ask, is it right I can't run test_line_item.py as separate file getting import error "No module named 'pay'? So far when I wanted to test my code I just run separate parts of it, but with import in siblings folders it's not possible.

  • @astronemir
    @astronemir 2 роки тому +6

    Thank you, this is exactly the nightmare I have to deal with. Instead of payment processors it’s expensive computations on gigabytes of data that need to be tested. Sigh. Can’t wait for part 2

  • @markasiala6355
    @markasiala6355 2 роки тому +8

    The monkeypatch example was particularly interesting. I've only used it some to test a method that called input function. However, I modified sys.stdin to place my input strings rather than replacing the input function. Is there a preferred method or are they considered relatively equal?

  • @niconeumann2963
    @niconeumann2963 2 роки тому +7

    Really great video! I love to see things about testing :)
    Wouldn't it be better to put only the line which raises an error into pytest.raises (like in try/catch) or why is all the code inside the block?

    • @ArjanCodes
      @ArjanCodes  2 роки тому +7

      Thanks Nico! Yes, good point, it would be better to only put the line that actually raises the error in the with statement, as this focuses the error detection better.

  • @henryw.4953
    @henryw.4953 2 роки тому +1

    etymology suggestion for monkey patch: 1) guerillia -> gorilla -> monkey; 2) monkeying about with code (en.wikipedia.org/wiki/Monkey_patch)

  • @Han-ve8uh
    @Han-ve8uh 2 роки тому +1

    1. At 9:40, why did test_order.py have only 77%? I thought all tests/ folder files will be 100% since all tests will be run by default. Anyway is there any reason to be checking for 100% coverage in files under tests/? Intuitively I would only care about coverage of the files they are testing, and not coverage of the test script itself.
    2. 14:20 def test_card_valid_date() contained no raises or assert. I thought every test would need one of these to communicate what is expected. Is this test function saying that if we can run without errors, then it passes? This feels wrong because even if it passes, it still doesn't clearly communicate the expected state, especially when there are many lines in the test function

  • @maikwiesmueller
    @maikwiesmueller 2 роки тому +1

    why using monkeypatch over unittest.mock.patch ?

  • @NostraDavid2
    @NostraDavid2 2 роки тому +4

    I'm so glad you've made this video, even though I don't need it anymore.
    I got a bit annoyed that there were so many Unit Test introductions, but nothing about what to do if you already have existing code, especially if said code contains a state, because all introductions have a nice, pure (meaning the function only has input and output - no sideeffects like printing text or saving files), function, which simply doesn't reflect reality.

  • @jevandezande
    @jevandezande Рік тому +3

    When writing code with pytest.raises, I recommend only putting the line that you expect to raise in the block, otherwise it might accidentally catch a failure that is happening elsewhere.

  • @vikingthedude
    @vikingthedude 2 роки тому +7

    You're quickly becoming one of my favourite programming tutorial channels. UA-cam has so much content which, on one end is all beginner programming concepts, and at the other end it's all frameworks and fancy programming features.
    I think you fill that gap in between where we take basic programming features and compose them in ways that make software development scalable and maintainable.

  • @Melindrea
    @Melindrea 2 роки тому +3

    Nice timing! I'm currently doing something like an internship where one of the things I'll be doing is to help betterify code written by my supervisor. One of the first things I'm going to be doing will be to set up tests and automate the various "did you write it appropriately".
    His code is quite good in general, but he has no tests, and when I asked if he used PEP-8 or another styleguide ... the answer was "I try to make sure to keep consistent tabs".
    I might not be able to help make the code itself better/faster (don't know yet!), but i will for sure be able to help make sure it's easier to refactor it and show that it's *working as it should*

  • @eyalbahar9291
    @eyalbahar9291 2 роки тому +4

    Honestly im so greatful for your videos.
    Im learning so much, enjoying my time and gertting alot of motivation to improve as a datascientist/developer.
    Thank you so much!!!!
    Youre awesome!

    • @ArjanCodes
      @ArjanCodes  2 роки тому

      I'm glad to hear the videos are helpful!

  • @jackanderson9258
    @jackanderson9258 2 роки тому +1

    When should I use assert vs self.assertEqual?

  • @rhernaus
    @rhernaus 2 роки тому +2

    Thank you for this valuable content. I have watched nearly all of your videos because I like the way you explain things. I'll start leaving comments on your videos to help the UA-cam algorithm even more 🙂

    • @ArjanCodes
      @ArjanCodes  2 роки тому +1

      Glad you like the content! And thanks for liking/commenting under the video. It’s indeed good to help the UA-cam algorithm, but I also find the feedback really helpful in improving the videos I post.

  • @mrswats
    @mrswats 2 роки тому +5

    Pytest is easily my favourite testing framework! And my favourite feature are fixtures! So easy to create and you can do all sorts of cool things with them too, parametrize, etc... What I am still struggling with is to do true TDD. I most often find myself having to do some exploration before being able to think what the tests will look like. Any ideas for that?

    • @veni_vidi_victorian
      @veni_vidi_victorian 2 роки тому +4

      I often start by thinking about the program flow and writing tests for the "intended flow" first. Then I think about what can go wrong and write tests for that. It's also important to remember that you can't test for every case, so do not feel too bad for missing something. Also, restricting per module helps a lot.
      Like in this video, the flow is "You have an item, order it, and get charged for the order.". So you first write a set of tests for the items, then the order, and finally the payment processor.
      When writing tests, the most essential part is not thinking of the implementation code but instead, "How would I interact with this object/function/...?".
      At least, those are my opinions/tips.

    • @TheStickofWar
      @TheStickofWar 2 роки тому +1

      @@veni_vidi_victorian good tips, emphasis on the last part. Thinking about how you would interact with it is more important than the implementation, good tests should also be able to tell a story of how you interact with the code base

    • @alchemication
      @alchemication 2 роки тому +1

      This is a great question and often asked. I would suggest exploring an idea completely separately (like for example in a Jupyter Notebook) and learning about API’s or error habdling, and then returning to TDD. There are many ways … 🖖

  •  2 роки тому +4

    Very interesting video, can't wait for part 2!
    You mentioned writing tests before the actual code. I wonder, how would this work for functions, that are computationally heavy, for example because they do some complex image processing, or perhaps create a 3D scene? How would you provide the correct result for the assertions? It's hard for me to imagine how this scenario would work.
    I'm only a beginner when it comes to programming, so I hope my question makes sense. :)

    • @ArjanCodes
      @ArjanCodes  2 роки тому +7

      Hi Dávid, if a function performs a very complex task, you would normally split up the function into several smaller functions that you can then test separately. For parts of your application that produce a complex result like a rendered image, a GUI, etc, a common technique used is snapshot testing. You generate the correct complex representation once and indicate this is the correct ‘snapshot’. When you change things in the code or add new features, the snapshot test verifies that the resulting output is still the same (or if it’s supposed to be different, you generate a new snapshot).

    •  2 роки тому

      @@ArjanCodes Got it, thanks for the explanation Arjan!

  • @zactamzhermin1434
    @zactamzhermin1434 2 роки тому +4

    Love your intermediate tutorials with examples + refactoring! Would love more TDD and software design patterns guides (for dummies + for non-dummies) as well as I can write code in a pretty straightforward manner but not so much with the mindset of a production setting with best practices. Also really nice setup :D

  • @FabianSlonimczyk
    @FabianSlonimczyk 2 роки тому +1

    Super interesting content. I have a question (open to anyone):
    I see that in testing with a "valid" card the expiry date is being hard coded. Would this not be a problem in the future, when the hard coded values become a "past date" and the tets are run again (and fail)? Thank you!
    PS (after watching part 2/2) My question is answered there!

  • @12valmirjr
    @12valmirjr 2 роки тому +3

    Arjan, you always exceed the expectations. Thank you once more for the content. The quality of the tips and the video itself are amazing!

  • @StellarEclipseStudio
    @StellarEclipseStudio 2 роки тому +2

    I hope you bring Mock into the conversation! Easier to use than writing lambdas and mock functions. Mock(side_effect=inputs) would have been a simpler way to monkeypatch the input calls.

    • @StellarEclipseStudio
      @StellarEclipseStudio 2 роки тому +1

      Mock is a class not well understood, I've had to teach other engineers about it many times. Well worth learning about if you're serious about writing test code! It's very powerful to use in conjunction with monkeypatch.

    • @Victorinoeng
      @Victorinoeng 2 роки тому

      Hey, @Joshua
      That is indeed an interesting functionality. Do you have any material to share?
      I have been using patch and magicMock, but feels so unnatural.
      Every time I have to Google/read up on some examples again

  • @splendorman7922
    @splendorman7922 2 роки тому +1

    how do i test functions that returns unknown data? like fetching from an api? or functions that do really complex calculations and you cannot know the result before running it?

    • @ericsalesdeandrade9420
      @ericsalesdeandrade9420 9 місяців тому

      Mocking for non-deterministic responses or validating the HTTP response code

  • @pericofalcor
    @pericofalcor 2 роки тому +2

    Awesome video, I really enjoyed it. It would be very interesting to see mocking applied to a database connection. I work with a 25 year old project in Perl, and a relatively younger Python code, and both have no tests at all. Both are inmense codebases and is usually seen as "imposible" to add unit testing to it. Everything is based on data stored in a mysql database, but I have no clue on how to even start testing when I have to mock so much data

  • @videohighlights6066
    @videohighlights6066 2 роки тому +1

    I would have also "asserted" that when the order item is created, its created with Status == OPEN

  • @universecode1101
    @universecode1101 2 роки тому +2

    Now we're all leveling up guys, great 👏🏻😊

  • @erikoosterwaal1844
    @erikoosterwaal1844 2 роки тому +1

    Doesn't 100% (or near 100%) coverage mean you're testing every decision tree branch in your code?
    If you do that, every little change in your code requires also changing a bunch of tests along with it.
    When you really want to use tests to be able to refactor more easily, shouldn't you test *intent*?
    For example, test the output of one unit of work, so you can change the underlying implementation and have your test confirm that your new implementation still yields the same results?

  • @marcgierse1601
    @marcgierse1601 2 роки тому +2

    Very good video - as always :-). Just one remark: If you don't want to have some tests suddenly fail on 1/1/2025, you probably want to use either something like the freezegun module or set the card info dynamically :-).

    • @ArjanCodes
      @ArjanCodes  2 роки тому +3

      Hi Marc, I’ll address this issue in part 2 this Friday.

  • @rodrigo2112-
    @rodrigo2112- 2 роки тому +2

    Great video! I'm catching up with your videos, so maybe you've done that already, but it would be a nice follow up to show how to create the same payment processing system and its tests if we were writing it using TDD from scratch, probably using dependency injection for the input and the payment service and therefore not need to monkeypatch

    • @ArjanCodes
      @ArjanCodes  2 роки тому

      Thanks and love that suggestion!

  • @LarsRindorf
    @LarsRindorf 10 місяців тому

    Hi Arjan
    It is a minor thing, but in 16:22, why do you prefer to use [int(d) for d in card_nr] rather than, e.g., list(map(int, list(d)))? Are there any benefits to this?
    Thanks

  • @ericalbertobernal101
    @ericalbertobernal101 2 роки тому

    Awesome. I am from mexico Your channel is fucking great. And thanks for sharing your knowledge. Keep the good work.

  • @JustMWest
    @JustMWest 6 місяців тому

    Excellent breakdown! I want to try it out but I can't for the life of me figure out how to import "pay" from within "tests". How does this work??

  • @sarkhanmammadli9673
    @sarkhanmammadli9673 2 роки тому +1

    Your videos are fantastic, and each time I am learning something new.

  • @eduardovega8851
    @eduardovega8851 Рік тому

    How is he able to import pay.OBJECT inside the tes folder files? Why is it not working for me ? Someone help! i have all my __init__ files

  • @MRBADGUY0027
    @MRBADGUY0027 10 місяців тому

    Hello Arjan, how does it look like if you've used "unittest" built-in lib? And why do you prefer pytest? Thnks

  • @marcocofano2545
    @marcocofano2545 2 роки тому +1

    Great one. Good point that you can realize where the code needs refactoring from writing unit tests. The tests that check raise value error can actually Raise it from different calls (one the init of the object and the other from the call of the method) so those tests are actually not unit and are not testing in the way they are intended.

  • @ArnoDunstatter-po7lv
    @ArnoDunstatter-po7lv 3 місяці тому

    Wish you explained the -cov flag and its associated plugin at the beginning of the video.

  • @rjgonzalez8108
    @rjgonzalez8108 2 роки тому

    Best python content here on YT. Also really like that shirt you're wearing. I would like to know where I can get one if you don't mind.

  • @jiazeli5419
    @jiazeli5419 2 роки тому

    Hi, why you write "if __name__ == __main__" in main script instead of module scripts?

  • @KarlaMuller
    @KarlaMuller 2 роки тому

    I'd love to know where you got that cool geometric led lights behind you. Also, big fan of all your content!

  • @meh.7539
    @meh.7539 2 роки тому

    Although, if you WANT to put api keys in your code for me to use, I'm happy to have those.

  • @codeaxen
    @codeaxen 2 роки тому

    Hello thanks for this video really helped... but is it possible to do a real payout system tutorial with stripe putting all these tests together ?

  • @Stewty1
    @Stewty1 20 днів тому

    great videos - but your github does not have the before/after of the test modules. Could you share the link to them please?

  • @danielwilkowski5899
    @danielwilkowski5899 2 роки тому

    8:30-10:00 Well, to be honest, it would be better if you first saw your tests fail somehow. Like maybe you could break your code intentionally, see the tests fail, and the restore.

  • @okdokie278
    @okdokie278 2 роки тому

    does anyone know which VSCode appearance theme is being used? :O

  • @vicentcaselles4807
    @vicentcaselles4807 10 місяців тому

    How do you import pay from the tests subfolder? It never works for me and I have to import it via relative imports which are so crappy

  • @tttooommm10
    @tttooommm10 2 роки тому

    I get a 404 from your 'buy me a coffee' page, is there a working link?

  • @amardeep.sahota
    @amardeep.sahota 2 роки тому +1

    I learned all these techniques hard way and hours of hard work. I wish I had come across your channel before. If you are a python developer, you can’t appreciate Arjans content enough this content is literally the abstract of years of hard work.

  • @jurybulich6324
    @jurybulich6324 2 роки тому +1

    Thank you Arjan, really glad that somehow UA-cam algorithms showed your channel) your content is very helpful! Nice

    • @ArjanCodes
      @ArjanCodes  2 роки тому

      Thank you Jury, glad the content is helpful!

  • @1234minecraft5678
    @1234minecraft5678 10 місяців тому

    I do get the argument that the compute total contains one of the more critical utilities of the code, but i also feel like it is one of the most trivial things to see weather the method is correct or not. If you add type hints while coding you can be 100% sure it works. i cannot see the benefit of adding a unit test in this case or am i mistaken?

  • @williamwei7899
    @williamwei7899 11 місяців тому

    why would we always want to test the invalid situation? is it just to see if it raises the Error we expected?

  • @johnwilliams7999
    @johnwilliams7999 2 роки тому

    Hmm could have tested invalid input, out of bounds values and so forth?

  • @cordempire4789
    @cordempire4789 2 роки тому

    Hey man - moved house and I need to redecorate. Where did you get that thing on your wall? I love it!

  • @UNgineering
    @UNgineering 2 роки тому

    tried to download the design guide, but when I enter my email it says "This value seems to be invalid"

  • @dianagera8413
    @dianagera8413 11 місяців тому

    Too easy for prod, all videos like this. is this only for entry level>?

  • @taylormonacelli
    @taylormonacelli 2 роки тому

    You're all dressed up these days. I need hacker hoodie back once in a while

  • @Izzat-bj1le
    @Izzat-bj1le Рік тому

    Amazing I love it, thanks for doing what u do

  • @Bentroen_
    @Bentroen_ 2 роки тому +1

    I just started delving into unit testing this week, so this video came at a perfect time!! Thank you so much, looking forward for part 2 :)

    • @ArjanCodes
      @ArjanCodes  2 роки тому +1

      Coming up on Friday 😉.

  • @Otakutaru
    @Otakutaru 2 роки тому +1

    I'm not doing this professionally, so I really doubt I will do many tests... But knowing how to is nice

    • @peterkruse8192
      @peterkruse8192 2 роки тому +2

      Depending on the size of your growing project tests will help you keep your own code stable while growing and extending it. If your feature set is very volatile tests will feel like a burden and overhead.

  • @PartScavenger
    @PartScavenger 2 роки тому

    I must say that I'm a little disappointed that he starts by understanding the code, and the method isn't a thousand lines long.
    That said I did learn a lot and I love this channel thank you for all the amazing content!!! Thanks for testing videos!! Please more!!!

  • @gw032sysint9
    @gw032sysint9 2 роки тому

    Could you please tell
    (1) how to do Unit Testing for decorators - both methods and class based?
    (2) Flask's request module throws lot of context related errors while patching how to resolve those?

  • @jerepovedamartinez4574
    @jerepovedamartinez4574 2 роки тому

    Hi Arjan, would be nice to know how to test very complex clases like the ones that usually appears in Deep Learning. For example, pytorch_lightning.LightningDataModule... things like the shape of tensors in several configurations, training loops, etc. I don't really know if it's worth to unit test somehow these kind of things. Currently, I'm placing asserts in my the code itself but not unit testing systematically, would be nice to know at least your point of view about this topic!

  • @condor07uk
    @condor07uk Рік тому

    test card valid date test did not assert anything

  • @andrewallbright
    @andrewallbright 2 роки тому

    Excellent example software -- too often I see horrible example code when talking about testing (which leads me to conclusions I will not say). Question: what are your thoughts about starting with writing acceptance tests for brownfield projects?

  • @morkallearns781
    @morkallearns781 Рік тому

    Any thoughts on pytest vs unittest?

  • @AgustinIgnacioGenoves
    @AgustinIgnacioGenoves 2 роки тому

    Thanks Arjan, thisvideo was super util for me.

    • @ArjanCodes
      @ArjanCodes  2 роки тому +1

      Glad to hear it was helpful!

  • @user-hk7wh9jm7l
    @user-hk7wh9jm7l 2 роки тому

    Hi . Would be awesome if you could make a video about agile principles. Thanks in advance :)

  • @kosmonautofficial296
    @kosmonautofficial296 2 роки тому

    great video thanks!

  • @ericandes4288
    @ericandes4288 Рік тому

    My professor assigned us to make unit test without ever telling us what a unit test is. Thank you for teaching me. I regret paying for college now lol

  • @sHillChannel
    @sHillChannel 2 роки тому

    I swear you have a hidden video camera in my office. You keep making videos on exactly what I am working on.

  • @InspektorDreyfus
    @InspektorDreyfus 2 роки тому

    Will the branch coverage (additional to line coverage) be in part 2?
    Can the coverage metric also be shown directly in the editor?

  • @abdelghafourfid8216
    @abdelghafourfid8216 2 роки тому

    very informative ! , I hope you'll cover also the type checking with mypy

  • @dariuszspiewak5624
    @dariuszspiewak5624 2 роки тому

    Arjan, is it only me or is your beard getting bigger and bigger, thicker and thicker from one vid to another? :)

  • @renatocustodio1000
    @renatocustodio1000 2 роки тому

    It seems that monkeypatch is even more powerful than Java's mockito in some aspects. Nice video.

  • @sriramjaisankar9121
    @sriramjaisankar9121 2 роки тому

    Hi Arjan, Are these tests possible when my application built on streamlit?

  • @gayathris2108
    @gayathris2108 6 місяців тому

    Found this to be simple and effective guide!!!

    • @ArjanCodes
      @ArjanCodes  6 місяців тому

      I'm glad to hear you enjoyed the video!

  • @lostinlunacy_
    @lostinlunacy_ Рік тому

    I have this exact structure used here with __init__.py in both test and src folders, but yet when running pytest I get ModuleNotFoundError, really baffling.
    Edit: I had to append to sys.path

  • @frankie_goestohollywood
    @frankie_goestohollywood 2 місяці тому

    Thank you Excellent, Arjan!

  • @rishabhahuja7413
    @rishabhahuja7413 2 роки тому

    Excited for the Part2!! Arjan please post it asap...

  • @beaumcdermott8742
    @beaumcdermott8742 9 місяців тому

    phenomenal editing job. Thanks for creating this. All content, no fluff, right to the point, no hemming/hawing, quick pace but calm delivery.
    I tip my hat to y'all. Subscribed and liked. Thank you for a top tier tutorial.

    • @ArjanCodes
      @ArjanCodes  9 місяців тому +1

      Thank you so much for the kind words, Beau!

  • @conconmc
    @conconmc 2 роки тому

    This is fantastic, eagerly waiting for the next video!!

  • @JacinLowe
    @JacinLowe 2 роки тому

    Long time watcher. This was the video i was waiting for. I'm learning how to do testing and didn't know where to start.

  • @RaghothamRao
    @RaghothamRao 11 місяців тому

    Thanks a lot! Very much helpful!

    • @ArjanCodes
      @ArjanCodes  11 місяців тому +1

      Glad you enjoyed the video :)

  • @pramithijagdish2821
    @pramithijagdish2821 6 місяців тому

    This was super helpful! Thanks for sharing.

    • @ArjanCodes
      @ArjanCodes  5 місяців тому

      Glad the video was useful!

  • @seanoverton798
    @seanoverton798 2 роки тому

    Great videos mate. Always learning something new from them.

  • @vbaclasses3553
    @vbaclasses3553 2 роки тому

    When you know the content is going to be worth the watch, so you like the video even before you start watching. Vreeslik baie dankie.

  • @mauisam1
    @mauisam1 2 роки тому

    #11 here. Can't wait until next week. Great video again!

  • @caioac1
    @caioac1 2 роки тому +4

    Although this is very helpful, I tend to think it's far from the reality of a big chunk of softwares written without test (and with bad architecture). If you have a Flask application (API only) that the route is calling a service, and service is coupled with SQLAlchemy for example (which is what 99% of tutorials/articles talk about basically), it's almost impossible to do unit testing, so you're left with integration tests only, which is fine but painfully slow. At the end of the day, if the application architecture is not great (clean, decoupled etc), unit test ends up being very difficult to write, except for very few specific functions.

    • @ArjanCodes
      @ArjanCodes  2 роки тому +1

      Unfortunately, this is very hard to do in a UA-cam tutorial since it would take way too much time to explain all the intricacies of the code, cleaning up the code and follow a layered architecture, and so on. It will lead to either a very long video, or a video consisting of many parts, both of which don’t work well on UA-cam. So I try to keep the example limited in scope while still trying to provide valuable information. It’s a trade-off.

    • @caioac1
      @caioac1 2 роки тому

      ​@@ArjanCodes Totally understand, and agree with the trade-off, not trying to diminish the video value in any way, please don't get me wrong. it is extremely helpful indeed. My comment is only to highlight the importance of architecture. I've tried to write unit test for existing applications, and found its nearly impossible if the system has a "bad" architecture, so the `assert 1+1 == 2` test case end up being very difficult to implement (if not impossible). Could be an idea for a future video, a "full" application architecture.

    • @ArjanCodes
      @ArjanCodes  2 роки тому +1

      No worries, and you’re absolutely right that the architecture plays a crucial role in being able to easily test your code!

  • @jankucera8505
    @jankucera8505 2 роки тому

    Why would I make a test for an error which I know how not to make?

    • @ArjanCodes
      @ArjanCodes  2 роки тому +1

      Because you might not be the only one working on the code. Or you might introduce the error accidentally by changing something somewhere else in the code.

  • @syspogh1609
    @syspogh1609 Рік тому

    Thanks Arjan for this good video.