Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
MinUnit - a minimal unit testing framework for C (jera.com)
4 points by wfn on May 7, 2013 | hide | past | favorite | 1 comment


The essence is here - pasting the (whole) source code:

    /* file: minunit.h */
    #define mu_assert(message, test) do { if (!(test)) return message; } while (0)
    #define mu_run_test(test) do { char *message = test(); tests_run++; \
                                   if (message) return message; } while (0)
    extern int tests_run;
> Conclusion

> People think that writing a unit testing framework has to be complex. In fact, you can write one in just a few lines of code, as this tech note shows. Of course, if you have access to a full-featured testing framework like JUnit, by all means use it. But if you don't, you can still use a simple framework like MinUnit, or whip up your own in a few hours. There's no excuse for not unit testing.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: