cateof
cateof

Reputation: 6758

regression test for command line program in C/C++

I have a linux utility that parses structured input ( a text file ), processes it and prints the result to the screen. For example: (input)

COMMAND=create
    NAME=Stack
    SURNAME=Overflow

My utility takes as input the above text file and tries to create an object (stack, overflow) in the database. If the action is executed successfully my program returns something like this:

COMMAND=create
    Code=0
    Result=OK

or in case of error

COMMAND=create
    Code=10
    Result=Duplicate entry

I am looking for a good way to create a regression suite for my binary. Any ideas that fit my case? Is any alternative to JUnit in C/C++?

Upvotes: 2

Views: 1433

Answers (2)

drew212
drew212

Reputation: 506

Google test is an awesome C++ framework, but it has a bit of a learning curve: https://github.com/google/googletest/

Upvotes: 3

StAlphonzo
StAlphonzo

Reputation: 766

I recommend CTest, which is part of CMake. It's pretty easy to configure and adding a test is as as simple as creating a test executable and calling TEST("Code should be 0", Code=0, true); Or something similar ... and it works for both c and c++ ;)

Upvotes: 1

Related Questions