Skip to content

How to Actually Run Criterion Tests? #516

Answered by Snaipe
lordmichael95 asked this question in Q&A
Discussion options

You must be logged in to vote

Hey there,

The main problem is that you're mixing your library code with your executable code. You seem to be linking criterion to your executable, which defines main, but your main overrides the default main that criterion provides.

Instead, you should introduce a third file that contains your code, and leave your main function in main.c.

You'd then have two executables: one for your main project, which links main.o and all of your library object files, and one for the tests, which links your library object files, your test object files, and libcriterion.

You can see this in action by compiling and linking directly one of the samples of this repo.

Alternatively, here's something I cooked…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@lordmichael95
Comment options

Answer selected by lordmichael95
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants