-
Notifications
You must be signed in to change notification settings - Fork 34
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
Testing CLI apps #9
Comments
|
Crates we can help:
|
Along with dir-diff (which I have PR out to make it more customizable / richer reporting), something I've been considering is different file system assertions, kind of like the |
Interested in working on this 👍 |
I will add a note here that testing your application with symbolic links (if relevant) is important, and doing it on Windows can be quite difficult. In one sense, it's hard because unlike in Unix, you have two different methods for creating symbolic links (one for directories and another for files). In another sense though, and the part that has been a real pain point for me, is that Windows by default doesn't let you create symbolic links. Instead, you need to toggle some permission setting for it to work. I believe Appveyor handles this for you, but if you're testing on a real Windows machine, you need to do it yourself. |
Testing with FS access could be done with
So we have crates for emulating FS access in tests. |
My current thoughts
file system mocking feels off to me. imo dealing with a file system means you are writing integration / end-to-end tests. Generally there is an application-specific abstraction that can exist above the file system that can instead be mocked. This can work for both unit and integration tests. For end-to-end tests, you want to verify the file system interactions and shouldn't mock it. |
I've updated the original issue to try to summarize what we've come up with so far. |
@killercup's tests for waltz are an experiment in a high level, more declarative way of writing a test for a program. Our thought has been to create individual building blocks and then put them together into something kind of like whats in waltz's tests. The priority is on the building blocks. A possibly controversial and further down the road thing I was considering was the need for various types of tempdirs. The program might be run within one and you might need to pass some to the program as flags. Ideally, the test framework would track these tempdirs and close them at the end, ensuring they can (on windows) and that they don't report errors. This got me wondering if we'll want some form of string templating in this so you can make the tempdir's path available as a variable that can then be accessed when creating a flag. |
Another issue about testing CLIs is to correctly calculate code coverage. If using |
@mssun That is a good point but I'm expecting that won't be too much of an issue. End-to-end testing using If there is an enterprising person who has an idea on how to solve that, great! Otherwise, we should call this out as an known issue in |
Ideally, we can use It is impossible to build both binary and tests with Because this command And using the Overall, I think the testing coverage issue is related to many parties such as: |
(moderated summary by @epage)
Context
Common inputs to a CLI
Common outputs to a CLI
Plan of Attack
Testing crate(s)
touch
filesIn-ecosystem resources
Challenges
@killercup's original post
In the first meeting, we identified that testing CLI apps cross-platform is not trivial and that we want to improve the situation.
The text was updated successfully, but these errors were encountered: