Skip to content
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

Find out how to test interactive UI #95

Open
untitaker opened this issue Feb 13, 2017 · 7 comments
Open

Find out how to test interactive UI #95

untitaker opened this issue Feb 13, 2017 · 7 comments
Labels
contributions welcome Further design discussions and PRs are welcome. enhancement lv: hard RGSoC

Comments

@untitaker
Copy link
Member

We currently don't test anything from the interactive UI because it's too hard. But it would be interesting what testing would look like. See #94 for a very recent example of where this became a problem

@untitaker untitaker added enhancement contributions welcome Further design discussions and PRs are welcome. lv: hard labels Feb 13, 2017
@WhyNotHugo
Copy link
Member

WhyNotHugo commented Feb 17, 2017

My best idea so far is to implement a dummy Screen, and test against that (with some help from mock, probably).

See here for more relevant documentation.

@untitaker
Copy link
Member Author

I had hoped that there already is a testing framework/library for urwid. This is why I tagged this as lv: hard, because eventually we'd need to come up with our own.

@untitaker
Copy link
Member Author

Also whatever we come up with should ideally be reusable outside of todoman, particularly khal.

@WhyNotHugo
Copy link
Member

So here's what I'm thinking right now:

  • Implement a screen-like class that doesn't do any outputting. I might just subclass that implementation and point output to /dev/null. If this turns out too complex, just write a class from scratch.
  • Instances of this class receive a list of keys, that it will simulate were pressed in that order (by returning them via get_input).
  • Write a test with a set of key-pressed, and check that the result (in the database) is the expected one, and that no exception were thrown.

This is a very high-level functional test, and not actual unit testing. Unit testing individual components can probably be done some other way.

We don't actually validate that thing look how we want them to, only that they behave how we want them to. The html_fragment display module can do that.

@untitaker
Copy link
Member Author

untitaker commented Feb 18, 2017 via email

@WhyNotHugo
Copy link
Member

Maybe we can use/borrow this html comparison assertion code.

Otherwise yes, we could write our own display module based on the HTML one (I'm guessing lots of its logic would be reusable).

@untitaker
Copy link
Member Author

It appears that #170 introduces some sort of UI test. I suspect an easier approach would be to create a fake urwid.MainLoop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributions welcome Further design discussions and PRs are welcome. enhancement lv: hard RGSoC
Projects
None yet
Development

No branches or pull requests

2 participants