turtle icon indicating copy to clipboard operation
turtle copied to clipboard

Hiding Messages

Open zichaelpath opened this issue 6 years ago • 3 comments

Hello, When using turtle, I'm aware of the expectation fulfilled and unexpected call messages are designed to let you know if you miss a mocked class function call, but is there a way to suppress those calls when you don't know how many times the function is going to be called? in one of our classes, we have a function being called in a thread, however I'd rather not see "expectation fulfilled" 500+ times to either the console or the text file we are writing to. any advice on how to suppress them, or was the library not designed to work that way?

zichaelpath avatar May 29 '19 19:05 zichaelpath

You can control how many times you expect a call to happen including 'any number of times', see http://turtle.sourceforge.net/turtle/reference.html#turtle.reference.expectation.invocation If for some reason this does not help you could use a custom error policy, see http://turtle.sourceforge.net/turtle/customization.html#turtle.customization.test_framework_integration but I wouldn't really think this would be needed in you case.

mat007 avatar May 30 '19 10:05 mat007

I meant more along the lines of hiding them all together, at least in the scenario of executing a thread where we don't know when the thread will exit (it exists in a while loop). for right now I've set the tests into individual test cases, each one covering a scenario, but I would like to point out that the file on our test system has a maximum file writing size of 100 KB, practically all of which is used to display the "expectation fullfilled" messages that turtle and boost output.

zichaelpath avatar May 30 '19 13:05 zichaelpath

Oh right, sorry, I slightly misunderstood your issue…

From what you're describing it seems you're logging Boost.Test outputs to a file, right? The "expectation fulfilled" messages are logged with level boost::unit_test::log_successful_tests i.e. Success as described in https://www.boost.org/doc/libs/1_70_0/libs/test/doc/html/boost_test/test_output/log_formats/test_log_output.html So you can either lower the log level, see

  • https://www.boost.org/doc/libs/1_70_0/libs/test/doc/html/boost_test/test_output/logging_api/log_ct_log_level.html#ref_log_level_explanations
  • https://www.boost.org/doc/libs/1_70_0/libs/test/doc/html/boost_test/utf_reference/rt_param_reference/log_level.html

(there is probably an environment variable as well) or as I mentioned before use a custom error policy in turtle http://turtle.sourceforge.net/turtle/customization.html#turtle.customization.test_framework_integration You can take simply copy the default one https://github.com/mat007/turtle/blob/master/include/turtle/error.hpp and remove the logging in call.

mat007 avatar May 30 '19 13:05 mat007