Live data from Hacker News

MinUnit – A minimal unit testing framework for C (2002)

jera.com

1–10 of 56 posts

Re: MinUnit – A minimal unit testing framework for C (2002)

#7
post #2

So, the revelation is that a unit test is an if statement, and if you wrap that into a macro you can call it a framework.

For many novice engineers this is a huge revelation.

Really? Is it perhaps because of those libraries that do their best to make test call sites look like weird pseudo-English. Stuff like having a library function named it():

it(“should be confusing”, function() { ... })

Re: MinUnit – A minimal unit testing framework for C (2002)

#9
Why not just 1 line? Of course, the application will halt after one test fails, but some people like it this way.

    #include 
Usage:

    void test_foo() {
        assert(foo() == 4 /* foo should be 4 */);
    }
Output would be something like

    Assertion failed at "foo() == 4 /* foo should be 4 */"
If you run the application in a debugger like GDB, you can see the frame when the abort trap is called.

Re: MinUnit – A minimal unit testing framework for C (2002)

#10
post #7

Earlier quoted context omitted.

For many novice engineers this is a huge revelation.

Really? Is it perhaps because of those libraries that do their best to make test call sites look like weird pseudo-English. Stuff like having a library function named it(): it(“should be confusing”, function() { ... })

It always really bothered me that there had to be so much syntactical sugar on top of testing frameworks. Unit testing should be written in exactly the syntax of the language you are working with. I don't want to have to carry that additional crap in my working memory while writing code. I can't stand having to look up Gherkin syntax just to write a few dumb tests.

The only reason I see the usefulness of additional syntax just for tests is the case to have non-technical people writing tests. From my experience, this is a terrible idea.

Post reply on HN