Project Setup: Automated Testing with Make (using queue example)

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

КОМЕНТАРІ • 55

  • @TheCocoaDaddy
    @TheCocoaDaddy 3 роки тому +24

    Bravo!!!! At my first programming job, we used make for a lot of our regression testing along with a ton of other stuff. We didn't use a framework, so we wrote unit test programs that tested all of our base classes. We wrote integration test programs to test our application and we used it extensively for environment setup (e.g. database "priming") and for test result comparison (e.g. report comparison, in some cases). I don't use make at all now, but sometimes I miss the "old days". Given the right targets, I could make a code change and run only the related tests OR I could run make "clean" and run the full regression suite. At one point, we had so many test cases, we had to split our build into two: one that ran the regression tests deemed most important to run and one that ran absolutely everything. I believe the second one had close to 300 tests (maybe a little more). Anyway, GREAT video and thanks for posting!

  • @fillempie1501
    @fillempie1501 3 роки тому +6

    Good tip!. I found testing frameworks always clumsy to use. This one is rather easy.
    Have already used it and found some bugs in my functions.
    Implemented the tests it in my autotools setup.

  • @neillunavat
    @neillunavat 3 роки тому +9

    I didnt even know you can do testing with make :o
    I owe all my C and C++ knowledge to you. Thank you so much.

    • @JacobSorber
      @JacobSorber  3 роки тому +1

      Any time!

    • @neillunavat
      @neillunavat 3 роки тому +1

      @Newtube link me resources. I am a bit naive being self taught.

    • @neillunavat
      @neillunavat 3 роки тому +1

      @Newtube im just 15 bruv. But yeah, i know what i need to know and i only watch those that i find informative like Mr. Jacob. Just love his videos...

    • @KarlKatten
      @KarlKatten 3 роки тому +1

      @Newtube Imagine complaining about the quality of someone's work when you literally just post stuff other people have made

  • @codebreakthrough
    @codebreakthrough Рік тому +1

    This video has been tremendously helpful, thank you!

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

    Always.... Always learning something new and useful on your channel....

    • @JacobSorber
      @JacobSorber  3 роки тому +1

      Wonderful. That's the goal.

    • @neerajkale
      @neerajkale 3 роки тому

      @@JacobSorber FYI, in one of my previous companies, we used Robot Framework for Integration/Feature testing for an ECU for cranes. I never got a chance to look into how things have been setup, probably because I joined the project when 70% work was done, but all I remember is that we wrote few test keywords in a python file, write test cases in a txt file using those keywords and test the new Application feature that we wrote in C.
      It was pretty easy to use and would give a nice result output in an html file.

  • @timokkko
    @timokkko 3 роки тому +7

    Could you make a follow up video about how to ensure that a test is not actual using periferal hardware but uses mocks or stubs?

  • @lucasteixeira5346
    @lucasteixeira5346 3 роки тому +1

    Extremely useful video. Clear and meaningful info. Thanks a lot

    • @JacobSorber
      @JacobSorber  3 роки тому

      You're welcome. Glad it was helpful.

  • @jessiehopper
    @jessiehopper 3 роки тому +1

    I've been using the Catch2 framework to test my C code lately. It requires only that you add one header file and you're good to go.

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

    You post some really legit content.

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

    This is cool! I've often wondered how "you people' do automated testing in C.

  • @dzious
    @dzious 3 роки тому +1

    Hi,
    Just a little warning, I've got a ln issue few years ago with criterion. When I used a structure with more than 12 elements (if I remember correctly) it used to make tests fail.
    An other library that you can use to test your code which doesn't have this issue is Gtest (from Google)
    Overall this is a good video as always. Really good introduction to tests and how to implement them in a project.
    Maybe you should just add a link to Criterion in the description to make it easier for people to find the lib and the assertion references.
    I'll add few commands to my comment later on which can be useful with criterion

    • @JacobSorber
      @JacobSorber  3 роки тому +1

      Interesting. Thanks. I haven't run into this issue, but I might just not put enough things in my structs. 🤔 I'll have to check it out.

  • @vvinoth514
    @vvinoth514 3 роки тому +4

    ❤️ From India

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

      ❤ from South Carolina. Thanks for being here.

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

    really great!

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

    Great video,. I notice that Criterion doesn't support mocking. What mocking package do you use with it?

  • @rohitjoshi4341
    @rohitjoshi4341 3 роки тому +1

    I really like your videos on make. I would appreciate if you could provide videos where we can use makefile to link 3 party libraries like boost (header files libraries) and unlike boost lib. In both way shared or dynamic linking and static linking.
    Also, I would like if you can make videos on best practices while making a makefile.
    Also, my personal question can we use a nested makefile. I mean we add makefile of small projects then combine them to make a bigger one while making the project. If we can can you add how to do it. Also, best practices for it.

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

    Great video as always 🙏 Now there is no excuse anymore to not use unit testing in my current/following project 👍 One general question about unit testing: Would you only test the interfaces (.h files) or also functionality in the actual implementations (.c files) with unit testing? For me, my naive concept of unit testing is just testing the interfaces. Is that too narrow? Best wishes from Munich! ☀️

    • @JacobSorber
      @JacobSorber  3 роки тому +3

      Hi Thomas! I would recommend testing everything you can. The smaller the "units" are that you are testing, the easier it is going to be to make sure you're testing everything. Testing the external-facing interfaces is usually easier than testing internal auxiliary functions. And, if testing those internals becomes too painful, that's ok. The point is to make sure that your tests exercise all of your code - all of your functions/lines of code as well as each of your interesting edge cases. So, the bigger the "unit" the more thought needs to go into testing it thoroughly. I hope that helps. Best of luck with the project.

  • @muhammedthahirm423
    @muhammedthahirm423 Рік тому +1

    is it fine if we haven't freed memory in test file. will it automatically be freed if any exception occurred?

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

      Any time a process ends, any non-shared memory will be unmapped.

  • @neerajkale
    @neerajkale 3 роки тому +3

    Looking forward to CMake.

  • @chonchjohnch
    @chonchjohnch 3 роки тому

    My habit is to create my first make statement with all my settings and files and whatnot and then factor things out

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

    Extremely useful!
    Question: is it a good method for cross-compilation?
    I mean, I develop for MCU but compile on my linux desktop.
    Or I have to somehow run tests on a target?
    thanks

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

    How can I write my unit tests when using an IDE like MPLAB X? If I create a new folder named tests and in it, I write my unit tests; I don't want them to be compiled and be part of the actual code that will go into the microcontroller. I only want to run the unit tests when I need to or whenever I build the main code. Please guide as I'm very new to this.

  • @michealking6425
    @michealking6425 3 роки тому +1

    Where can I get the criterion library on windows?

  • @sleepib
    @sleepib 3 роки тому

    Any ideas for automated testing of embedded code? The only thing I can think of that sounds like a reasonable use of time is to choose a platform like raspberry pi, where you can develop on the target hardware, or at least something close enough to run natively. Though I don't have any ideas for something like an 8051 microcontroller.

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

    hi
    Iam new to automated unit testing , i have followed you in this vedio and try to frame this framework,but dont know why i cant able to get output as it shows in your system .In my case makefile is not linked with test file and getting this in output screen
    ar -cvrs lib/hello.a obj/hello.o a - obj/hello.o for test in ; do ./$test; done
    can you please help me with this..

  • @sumdim6427
    @sumdim6427 3 роки тому

    Nice!

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

    Word of warning with the $(RM) it can and will remove your OS and code if you're not careful. I lost a week of work and a bunch of OS configuration when i went to make and it ran the clean step. Be very careful to make sure you've got it right before running make as you won't know that it's destroying everything before its too late

  • @honey-py9pj
    @honey-py9pj 3 роки тому

    I know it's called unit testing but in order to check my result for a school assignment which may include multiple functions (or any expect of main) , can I still use a unit testing framework and treat my whole program as a function? to test?

  • @k8236
    @k8236 3 роки тому

    Great video Jacob! How would I go about using criterion on another machine-VM gets the code from a git repo? Any help would be greatly appreciated!

    • @JacobSorber
      @JacobSorber  3 роки тому +1

      Yes, you could do it that way. I often use vagrant to create the VM and then just share a folder between host and guest. But, a git repo would work, as well.

    • @k8236
      @k8236 3 роки тому

      @@JacobSorber I ended up using a modified minunit setup! Just made it fancy with colours and more testing options! Thank you.

  • @KangJangkrik
    @KangJangkrik 3 роки тому

    Any idea how to use CMAKE instead? My team currently using CMAKE as a build tool but we use python instead to test because nobody knows how to do that in CMAKE

  • @LeFede
    @LeFede 8 місяців тому

    how can I use it on windows?

  • @sumitbhosale3401
    @sumitbhosale3401 3 роки тому

    Nice Explantion. But Can You Please Make On Video In Graph. Thanks

  • @DipankarDas-cm1zs
    @DipankarDas-cm1zs 2 роки тому

    Which is the best testing framework?

  • @wilfreddv
    @wilfreddv 3 роки тому

    The "Test" functions (?) look weird to me, and especially the TestSuite one with the `.init=suitsetup`. Can someone tell me what is going on? Heavy preprocessor use?

    • @killermonkey1392
      @killermonkey1392 3 роки тому

      Without having looked at it at all, I'll take a wild guess and say that most of it are infact preprocessor macros, and that the `.init=suitesetup` are probably copy-pasted into a Struct initialization.

  • @diceandbricks
    @diceandbricks 3 роки тому

    Nice. How does criterion detect and call each test case?

    • @dzious
      @dzious 3 роки тому +1

      Criterion uses macros to "detect" each test case and build its function at compile time if you use VScode you han hover the Test keyword and you'll see the implementation of it

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

    Is it a poor idea to just use a set of standard assertions to test rather than criterion?

  • @abcddd580
    @abcddd580 3 роки тому +1

    Dr.Sorber, do you use CMake? If so, I'd appreciate if you could do a series on it.

  • @rmando_v
    @rmando_v 3 роки тому

    Wow :0

  • @cernejr
    @cernejr 3 роки тому +1

    Please do not use make for testing in 2021, just don't. Use python, or some other readable and maintainable language/platform. For building projects make is still fairly competitive (especially when used with cmake), but for testing it is a really poor choice.