Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use GTest instead of CUnit #125

Closed
davidgraeff opened this issue Mar 27, 2016 · 2 comments
Closed

Use GTest instead of CUnit #125

davidgraeff opened this issue Mar 27, 2016 · 2 comments

Comments

@davidgraeff
Copy link

Regarding the advantages, look at the example here: https://github.com/google/googletest/blob/master/googletest/samples/sample1_unittest.cc.

  • Compared to CUnit no boilerplate code (table of test functions, manually registering those in a main() etc) is necessary.
  • Writing a new test case is as easy as adding a file new_test_suite.cpp and adding your test
TEST(TestSuiteName, TestName) {
  int a = test_important_func();
  EXPECT_EQ(1, a);
}

This of course only works seamlessly, if cmake collects all cpp files via file(GLOB) in tests/ and add it to the test binary.

  • GTest is C++: A C++ compiler have to be used to compile the tests (and only the tests),
    but you can continue to write tests in C of course.
@dnav
Copy link
Contributor

dnav commented Mar 30, 2016

It looks like a marginal gain. (especially if you compare to the effort to have Eclipse to validate the use of GTest ;) )

@davidgraeff
Copy link
Author

One last try, before I give up on that. I prepared a merge request for comparison (#132).

Look at that beautity. More than 150 lines could be removed. It is possible to use test fixtures (setup, test cases, teardown) for single test suits and native c++ features like threads would allow you to make complete client<-->server sessions testable. GTest allows to output the result in JUnit and TAP compatible files (thing of jenkins and other CI GUIs). Tests can be repeated and shuffled for detecting memory leaks.

But choosing another test framework is nothing to be rushed. But for mid and longterm it may be a little easier to constribute tests and test suits with something more modern.

@dnav dnav closed this as completed May 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants