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

preview_player
Показать описание
---

Project Setup: Automated Testing with Make (using queue example) // Continuing our recent series of videos about setting up programming projects, in this video I show you how to make automated testing easy by integrating it into your makefile, using the criterion testing framework. The example builds on the queue data structure from a previous video. Remember, if it isn't easy, you probably won't do it.

Related Videos:



***

Welcome! I post videos that help you learn to program and become a more confident software developer. I cover beginner-to-advanced systems topics ranging from network programming, threads, processes, operating systems, embedded systems and others. My goal is to help you get under-the-hood and better understand how computers work and how you can use them to become stronger students and more capable professional developers.

About me: I'm a computer scientist, electrical engineer, researcher, and teacher. I specialize in embedded systems, mobile computing, sensor networks, and the Internet of Things. I teach systems and networking courses at Clemson University, where I also lead the PERSIST research lab.

More about me and what I do:

To Support the Channel:
+ like, subscribe, spread the word

Рекомендации по теме
Комментарии
Автор

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!

TheCocoaDaddy
Автор

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.

fillempie
Автор

This video has been tremendously helpful, thank you!

codebreakthrough
Автор

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

lucasteixeira
Автор

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?

timokkko
Автор

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

neerajkale
Автор

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.

jessiehopper
Автор

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.

rohitjoshi
Автор

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

ivankryvosheia
Автор

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?

honey-pypj
Автор

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

edgeeffect
Автор

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.

neillunavat
Автор

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.

sleepib
Автор

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.

mrafayshams
Автор

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

KangJangkrik
Автор

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

jerrycrane
Автор

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

dzious
Автор

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! ☀️

tmbnes
Автор

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

rajamchakradar
Автор

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!

k