Testing c++ console output via TDD -


i writing c++ program using test driven development approach. have function uses console output. write test able test whether console output same expected output. saw can solved , should checked. saw solutions in forum not in c++ in other languages. suppose can done in c++ too.

any hint great help.

don't write directly console; write stream that's provided function.

the test can provide stringstream, , extract output that. real program can provide cout (or else) real output.

in general: write code interacts abstract interfaces, can mocked tests, rather concrete implementations, can't.


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -