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

  Рет қаралды 37,202

Jacob Sorber

Jacob Sorber

Күн бұрын

Пікірлер: 55
@TheCocoaDaddy
@TheCocoaDaddy 3 жыл бұрын
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!
@JacobSorber
@JacobSorber 3 жыл бұрын
You're welcome.
@codebreakthrough
@codebreakthrough Жыл бұрын
This video has been tremendously helpful, thank you!
@neillunavat
@neillunavat 3 жыл бұрын
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 жыл бұрын
Any time!
@neillunavat
@neillunavat 3 жыл бұрын
@Newtube link me resources. I am a bit naive being self taught.
@neillunavat
@neillunavat 3 жыл бұрын
@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 жыл бұрын
@Newtube Imagine complaining about the quality of someone's work when you literally just post stuff other people have made
@fillempie1501
@fillempie1501 3 жыл бұрын
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.
@neerajkale
@neerajkale 3 жыл бұрын
Always.... Always learning something new and useful on your channel....
@JacobSorber
@JacobSorber 3 жыл бұрын
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 жыл бұрын
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 жыл бұрын
Extremely useful video. Clear and meaningful info. Thanks a lot
@JacobSorber
@JacobSorber 3 жыл бұрын
You're welcome. Glad it was helpful.
@jessiehopper
@jessiehopper 3 жыл бұрын
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.
@jerrycrane6830
@jerrycrane6830 2 жыл бұрын
Great video,. I notice that Criterion doesn't support mocking. What mocking package do you use with it?
@edgeeffect
@edgeeffect Жыл бұрын
This is cool! I've often wondered how "you people' do automated testing in C.
@vvinoth514
@vvinoth514 3 жыл бұрын
❤️ From India
@JacobSorber
@JacobSorber 3 жыл бұрын
❤ from South Carolina. Thanks for being here.
@rohitjoshi4341
@rohitjoshi4341 3 жыл бұрын
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.
@muhammedthahirm423
@muhammedthahirm423 Жыл бұрын
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.
@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.
@benjaminshinar9509
@benjaminshinar9509 3 жыл бұрын
really great!
@dzious
@dzious 3 жыл бұрын
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 жыл бұрын
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.
@michealking6425
@michealking6425 3 жыл бұрын
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.
@t0m0b0nes
@t0m0b0nes 3 жыл бұрын
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 жыл бұрын
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.
@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
@LeFede
@LeFede 8 ай бұрын
how can I use it on windows?
@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..
@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
@neerajkale
@neerajkale 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
@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 жыл бұрын
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.
@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.
@sumitbhosale3401
@sumitbhosale3401 3 жыл бұрын
Nice Explantion. But Can You Please Make On Video In Graph. Thanks
@pseudopseudo3679
@pseudopseudo3679 Жыл бұрын
Is it a poor idea to just use a set of standard assertions to test rather than criterion?
@daniellowry
@daniellowry 2 жыл бұрын
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
@diceandbricks
@diceandbricks 3 жыл бұрын
Nice. How does criterion detect and call each test case?
@dzious
@dzious 3 жыл бұрын
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
@sumdim6427
@sumdim6427 3 жыл бұрын
Nice!
@DipankarDas-cm1zs
@DipankarDas-cm1zs 2 жыл бұрын
Which is the best testing framework?
@DipankarDas-cm1zs
@DipankarDas-cm1zs 2 жыл бұрын
for C
@abcddd580
@abcddd580 3 жыл бұрын
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 жыл бұрын
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.
The Good and Bad of Automatic Make Rules
11:24
Jacob Sorber
Рет қаралды 9 М.
How to make memory read-only in your C programs.
12:57
Jacob Sorber
Рет қаралды 20 М.
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 83 МЛН
Introduction to Jest Testing | JavaScript Unit Tests
25:30
Dave Gray
Рет қаралды 33 М.
Student programmers, ChatGPT is not your friend
13:46
Jacob Sorber
Рет қаралды 12 М.
Do you even test? (your code with CMake)
12:38
Code for yourself
Рет қаралды 26 М.
How to Write Function-Like Preprocessor Macros (C example)
13:59
Jacob Sorber
Рет қаралды 43 М.
Java Unit Testing with JUnit - Tutorial - How to Create And Use Unit Tests
21:35
Make your Data Type more Abstract with Opaque Types in C
13:41
Jacob Sorber
Рет қаралды 51 М.
How do I access a single bit?
11:07
Jacob Sorber
Рет қаралды 22 М.
Next.js with React Testing Library, Jest, TypeScript
25:04
Dave Gray
Рет қаралды 72 М.
When do I use a union in C or C++, instead of a struct?
11:18
Jacob Sorber
Рет қаралды 70 М.
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН