den
den copied to clipboard
Command tests
Create unittests for commands:
- [ ] install
- [ ] uninstall
- [ ] fetch
- [ ] spec
- [ ] pull
Removed completion
since all the code for that is in the unscripted
package. And unscripted already has tests for it.
@seaneagan, Instead of hardcoding every testing case, I want to intelligently autogenerate them. I've been working on install
first as a model for the others. I want to develop a helper class that performs the combinatorics and auto-generates these testing cases. Pardon anything incorrect in the following as I have no formal math background.
Briefly described, I imagine a σ-algebra set of possible arguments (flags, options and rest) and an expectancy set of outcomes. The testing set is a subset of this σ-algebra.
For example for install
,
Let R be the set of rest arguments: prompt, chrome, chrome#0.6.5, git://github.com/seaneagan/unscripted.git, ...
.
Let O be the set of options: source:hosted, source:git, source:local
.
Let F be the set of flags: dev:false, dev:true
.
Let E be the expectancy set of pubspec outcomes: yaml contains prompt, yaml contains chrome, ...
The resulting testing set σ-algebra on R, O, and F would be
[prompt, source:hosted], [prompt, source:hosted, dev:true], ...
I don't know how to express this in set theory but I imagine also excluding the following cases, for example, as they are impossible:
[git://github.com/seaneagan/unscripted.git, source:hosted], [prompt, source:local]
@damondouglas unscripted
(which den uses) was designed to allow you to unit test the dart method(s) or class(es) that represent your command-line interface and not have to actually test the command-line interface itself by passing command-line arguments to it. So let's start with that, and then if that doesn't seem sufficient we can look at doing some integration tests that actually run the process. +1 for starting with a single command as a PR.
So for example you would want to unit test InstallCommand
.
@seaneagan , Next week I will provide my first PR for this. Just letting you know I'm still active and excited to work on this.
@seaneagan , I'm struggling with executing unittests with async methods. I need to step away for a while and come back with a fresh mind.
@seaneagan , I finally figured out how to test within an async context. At some point I am going to do another PR. Meanwhile, please see my progress: https://github.com/damondouglas/den/tree/master/test