-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] How to unit test Brick apps #447
Comments
Was there any update here since this issue was raised? |
I can't speak for the repo maintainer, but for me personally, I've been able to get by with just the test helper function that I posted in the collapsed details block in the original post, and haven't had enough need to try to generalize or improve it. But anyone can feel free to use that code I posted for any purpose. |
I can't report any changes, either. I was really just in a spectator mode on this ticket in case @avh4 came up with something promising. :) It sounds like maybe we've discussed all we can at this point, though, so I'll close this. Please re-open if there's more to discuss. |
I had been looking for some info on how to do this and didn't find it, so I figured I'd share my progress here.
This is a function that can start a Brick app using the Graphics.Vty.Output.Mock mock terminal, simulate the given list of
Vty.Event
s, and then return the final output of the mock renderer. (Note, the mock vty output is a bit weird; the reference of the weird characters it outputs can be seen in it's source code.)the test function (click to expand)
runApp :: Ord n => Brick.App s e n -> Vty.DisplayRegion -> s -> List Vty.Event -> IO Text
I'm hoping to eventually clean this up and contribute it to brick itself if there's interest, but there are a few missing pieces still to do:
Text
renderer (see Mock render Widgets #405), as theMock
renderer isn't really meant for this use and has an output format that is a bit weird and incomplete for the use of testing apps from an end-user perspectiveThe text was updated successfully, but these errors were encountered: