I'm developing terminal app. And I'm wondering how can one test the terminal user interface made with ncurses. Does any one have some experience with this kind of testing?
So far my best shot will be to test app with capturing stdout and compare it with what it should be. But I'm concerned that i could never create the comparable case for every terminal size, text colors codes for (256bit,24bit), etc...
One way to test would be to simulate the keyboard but how could I test the visual behaivour?
I am clueless obout this problem...
Comparing screen output is difficult, since ncurses updates only the altered parts of the screen, using cursor-addressing and other methods. Instead, comparing the content of the screen known to ncurses at different points in time is the best approach.
You could construct a screen-dump using instr to get the text (but that omits attributes such as color). The Python interface to ncurses also has inch (but that assumes characters are 8-bits)
It would be nice to use putwin, but that (until recently) saves the window in binary form. Upcoming ncurses6 uses a text dump, which could be diff'd. The change is not visible to callers (since putwin/getwin always have treated the file-format as a secret), and in principle could be turned on in a build of ncurse5. For that, you would probably have to build your own ncurses.