Live data from Hacker News

Show HN: Writing modern C unit tests with Criterion

github.com

1–10 of 14 posts

Re: Show HN: Writing modern C unit tests with Criterion

#2
Developer here.

I made this unit testing framework out of frustrations I had (and still have) with other C frameworks like CUnit or Check.

I wanted to make something much more simple, yet as powerful, and I think (and hope) I nailed it pretty much after a few months of work.

If you have any questions or suggestions, feel free to ask :)

Re: Show HN: Writing modern C unit tests with Criterion

#3
post #2

Developer here. I made this unit testing framework out of frustrations I had (and still have) with other C frameworks like CUnit or Check. I wanted to make something much more simple, yet as powerful, and I think (and hope) I nailed it pretty much after a few months of work. If you have any questions or suggestions, feel free to ask :)

Did you check out Greg Banks' Novaprova?

Re: Show HN: Writing modern C unit tests with Criterion

#5
post #3
post #2

Developer here. I made this unit testing framework out of frustrations I had (and still have) with other C frameworks like CUnit or Check. I wanted to make something much more simple, yet as powerful, and I think (and hope) I nailed it pretty much after a few months of work. If you have any questions or suggestions, feel free to ask :)

Did you check out Greg Banks' Novaprova?

Actually, I didn't know about it until now! The project uses a similar approach to mine, by parsing the DIE tree produced by dwarf, which means that it won't work if you're not compiling with -g.

It also uses some very platform specific stuff, so windows & os x are out, too.

Very well made nonetheless.

Re: Show HN: Writing modern C unit tests with Criterion

#6
post #5
post #3

Earlier quoted context omitted.

Did you check out Greg Banks' Novaprova?

Actually, I didn't know about it until now! The project uses a similar approach to mine, by parsing the DIE tree produced by dwarf, which means that it won't work if you're not compiling with -g. It also uses some very platform specific stuff, so windows & os x are out, too. Very well made nonetheless.

I think he's got OSX running now, but as you say -- it relies on some platform-specific stuff.

Good to see C test frameworks doing some innovative stuff!

Re: Show HN: Writing modern C unit tests with Criterion

#7
post #4

personally I use Glib test ( https://developer.gnome.org/glib/stable/glib-Testing.html ) for c testing, but I'll check this out. Does this let you test what a program sends to stdout and stderr, and let you trap a subprocess to test that the program exits right?

By default, if the test raises any signal or exits with anything other than 0, the test fails.

Otherwise, you can't (yet!) test if the code exits with a specific value nor simply redirect input/output, but I'll be sure to take these suggestions into account, thanks!

Both will be implemented quite soon.

Re: Show HN: Writing modern C unit tests with Criterion

#9
post #2

Developer here. I made this unit testing framework out of frustrations I had (and still have) with other C frameworks like CUnit or Check. I wanted to make something much more simple, yet as powerful, and I think (and hope) I nailed it pretty much after a few months of work. If you have any questions or suggestions, feel free to ask :)

Why did you rule out using Google Test (https://code.google.com/p/googletest)?

(In case you mulled over using it.)

Re: Show HN: Writing modern C unit tests with Criterion

#10
post #9
post #2

Developer here. I made this unit testing framework out of frustrations I had (and still have) with other C frameworks like CUnit or Check. I wanted to make something much more simple, yet as powerful, and I think (and hope) I nailed it pretty much after a few months of work. If you have any questions or suggestions, feel free to ask :)

Why did you rule out using Google Test ( https://code.google.com/p/googletest )? (In case you mulled over using it.)

Google Test requires you to write your tests in C++ rather than C; so there was times I just could not use it.
Post reply on HN