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

javascript - three.js lot of meshes optimization -

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -