[GH-ISSUE #1060] How to unit test and e2e test? #766

Closed
opened 2026-03-04 01:07:35 +03:00 by kerem · 2 comments
Owner

Originally created by @williamhstone on GitHub (Dec 6, 2024).
Original GitHub issue: https://github.com/rivo/tview/issues/1060

How can I unit test my code? Is there some mocking that can be done with tview.NewApplication and tview.NewPages?

Also, how can I end-to-end test? I want to bring up my app, update some form fields and validate the updates on screen?

Thanks!

Originally created by @williamhstone on GitHub (Dec 6, 2024). Original GitHub issue: https://github.com/rivo/tview/issues/1060 How can I unit test my code? Is there some mocking that can be done with tview.NewApplication and tview.NewPages? Also, how can I end-to-end test? I want to bring up my app, update some form fields and validate the updates on screen? Thanks!
kerem closed this issue 2026-03-04 01:07:35 +03:00
Author
Owner

@rivo commented on GitHub (Mar 29, 2025):

Adding unit tests to tview has been on my todo list for almost as long as the project exists. The idea is to create a special tcell.Screen object whose content is then extracted and compared after the test has run.

You might want to create something like that for you application. I haven't given it much thought, though, so I don't know the pitfalls of this technique yet.

<!-- gh-comment-id:2763509198 --> @rivo commented on GitHub (Mar 29, 2025): Adding unit tests to `tview` has been on my todo list for almost as long as the project exists. The idea is to create a special `tcell.Screen` object whose content is then extracted and compared after the test has run. You might want to create something like that for you application. I haven't given it much thought, though, so I don't know the pitfalls of this technique yet.
Author
Owner

@williamhstone commented on GitHub (Mar 30, 2025):

Thanks for the response!

On Sat, Mar 29, 2025 at 8:25 AM rivo @.***> wrote:

Adding unit tests to tview has been on my todo list for almost as long as
the project exists. The idea is to create a special tcell.Screen object
whose content is then extracted and compared after the test has run.

You might want to create something like that for you application. I
haven't given it much thought, though, so I don't know the pitfalls of this
technique yet.


Reply to this email directly, view it on GitHub
https://github.com/rivo/tview/issues/1060#issuecomment-2763509198, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AB5VZ3AT35APKE5M2WCVU2T2W2UMVAVCNFSM6AAAAABTDV3GO6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONRTGUYDSMJZHA
.
You are receiving this because you authored the thread.Message ID:
@.***>
[image: rivo]rivo left a comment (rivo/tview#1060)
https://github.com/rivo/tview/issues/1060#issuecomment-2763509198

Adding unit tests to tview has been on my todo list for almost as long as
the project exists. The idea is to create a special tcell.Screen object
whose content is then extracted and compared after the test has run.

You might want to create something like that for you application. I
haven't given it much thought, though, so I don't know the pitfalls of this
technique yet.


Reply to this email directly, view it on GitHub
https://github.com/rivo/tview/issues/1060#issuecomment-2763509198, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AB5VZ3AT35APKE5M2WCVU2T2W2UMVAVCNFSM6AAAAABTDV3GO6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONRTGUYDSMJZHA
.
You are receiving this because you authored the thread.Message ID:
@.***>

<!-- gh-comment-id:2764363505 --> @williamhstone commented on GitHub (Mar 30, 2025): Thanks for the response! On Sat, Mar 29, 2025 at 8:25 AM rivo ***@***.***> wrote: > Adding unit tests to tview has been on my todo list for almost as long as > the project exists. The idea is to create a special tcell.Screen object > whose content is then extracted and compared after the test has run. > > You might want to create something like that for you application. I > haven't given it much thought, though, so I don't know the pitfalls of this > technique yet. > > — > Reply to this email directly, view it on GitHub > <https://github.com/rivo/tview/issues/1060#issuecomment-2763509198>, or > unsubscribe > <https://github.com/notifications/unsubscribe-auth/AB5VZ3AT35APKE5M2WCVU2T2W2UMVAVCNFSM6AAAAABTDV3GO6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONRTGUYDSMJZHA> > . > You are receiving this because you authored the thread.Message ID: > ***@***.***> > [image: rivo]*rivo* left a comment (rivo/tview#1060) > <https://github.com/rivo/tview/issues/1060#issuecomment-2763509198> > > Adding unit tests to tview has been on my todo list for almost as long as > the project exists. The idea is to create a special tcell.Screen object > whose content is then extracted and compared after the test has run. > > You might want to create something like that for you application. I > haven't given it much thought, though, so I don't know the pitfalls of this > technique yet. > > — > Reply to this email directly, view it on GitHub > <https://github.com/rivo/tview/issues/1060#issuecomment-2763509198>, or > unsubscribe > <https://github.com/notifications/unsubscribe-auth/AB5VZ3AT35APKE5M2WCVU2T2W2UMVAVCNFSM6AAAAABTDV3GO6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONRTGUYDSMJZHA> > . > You are receiving this because you authored the thread.Message ID: > ***@***.***> >
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#766
No description provided.