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

Test Framework #23

Closed
tynes opened this issue Nov 26, 2019 · 3 comments · Fixed by #101
Closed

Test Framework #23

tynes opened this issue Nov 26, 2019 · 3 comments · Fixed by #101

Comments

@tynes
Copy link

tynes commented Nov 26, 2019

It would be ideal to add unit tests to hnsd so that its easier to develop without regressions. There are many options for test frameworks in C, many projects opt to roll their own framework. I found what I believe to be good options.

Options

  • cmocka

    • Used by bind, libssh
    • Custom assertions
    • Simple to use, create an array of CMUnitTests using cmocka_unit_test which wrap describe like functions
  • check

    • Designed to work with autotools
    • Simple, but a lot of boilerplate
  • CGreen

    • Large, has many features
    • TDD/BDD support, along with Before, After, etc macros
  • Custom

    • No extra dependencies
    • As simple as it needs to be
    • Must implement it, must be bugfree

I'd personally opt for using cmocka since it looks simple to use and is also used by other applications that are similar (DNS + security). It would be easier than creating our own custom test library.

@pinheadmz
Copy link
Member

pinheadmz commented Nov 26, 2019

We could use CI in the hsd repo too, CircleCI can install hnsd and we run it as a child_process with nodejs and run bmocha e2e tests. Tried a similar thing w bcoin: bcoin-org/bcoin#759

@tynes
Copy link
Author

tynes commented Nov 26, 2019

We could use CI in the hsd repo too, CircleCI can install hnsd and we run it as a child_process with nodejs and run bmocha e2e tests. Tried a similar thing w bcoin: bcoin-org/bcoin#759

That would be good for integration tests, I am thinking more along the idea of unit tests here. Unit tests would be useful in particular for the resource serialization.

@pinheadmz
Copy link
Member

Made some progress in #68 and expanded in #76 but it might be nice to import one of these existing frameworks in the future.

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

Successfully merging a pull request may close this issue.

2 participants