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

Add testing host methods #450

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

minimapletinytools
Copy link
Member

@minimapletinytools minimapletinytools commented Jan 16, 2021

This PR introduces test host module into Reflex to facilitate testing. There are two parts:

  • Reflex.Test.SimpleHost.hs - this is basically test/Test/Run.hs (and replaces it) converted into a more general use module
  • Reflex.Test.Monad.Host.hs - this module contains a monad for firing a reflex network and reading its outputs for the purpose of testing with an imperative syntax

This is a module is a merge of https://github.com/pdlla/reflex-test-host I think it's a good addition to the main reflex library. I also need Reflex.Test.Monad.Host for some of the work I plan on doing for reflex-vty.

I've already been using this library extensively in my project https://github.com/pdlla/potato-flow you can see many examples of usage in the test/*.

There's also a reflex-vty layer built over the testing monad. You can see some basic examples here https://github.com/pdlla/potato-flow-vty (see Reflex/Vty/Test/Monad/Host.hs and test/*) I'm also using this to test functionality I'm adding to reflex-vty. You can see a more sophisticated example of this here.

Note 1: this resolves issue #412
Note 2: happy to remove hspec dependency

@minimapletinytools
Copy link
Member Author

@ali-abrar this PR is for the base test module I've been using. See description for link to reflex-vty test module that's built on top of this.

I'm planning on writing UTs for reflx-vty using this test module so ideally I'd like this to be in the base reflex library so that I don't have to pull in pdlla/reflex-test-host as a dependency into reflex-vty (or some other solution).

Note, admittedly, the test monad is rather convoluted and I have only written very basic tests using it. Still, I think it's the right way to go and about as simple as it can be. I should be writing more complicated test cases soon-ish however I thought it'd be better to open this PR now to get the conversation going.

@minimapletinytools
Copy link
Member Author

review pls :)?

@minimapletinytools
Copy link
Member Author

making my quarterly check in to see if anyone is available to review :)

@Ericson2314
Copy link
Member

@pdlla perhaps it is fine, but I would be more confortable of the Reflex.Test helpers could go in a private "sub library". Expanding the public interface creates a permanent maintenance, so I am always a bit nervous to do so principle.

@minimapletinytools
Copy link
Member Author

@Ericson2314 that's fine with me. And I guess tests can also be moved to separate project so that the main library does not need to depend on it. A review would definitely still be appreciated.

Somewhat related: Is there any place where reflex libraries are documented? Not just for this library, but for other reflex libraries. That was definitely one of the biggest challenges for me when learning to use reflex--bad discovery on up to date supporting libraries and examples :(.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants