den icon indicating copy to clipboard operation
den copied to clipboard

Command tests

Open damondouglas opened this issue 10 years ago • 7 comments

Create unittests for commands:

  • [ ] install
  • [ ] uninstall
  • [ ] fetch
  • [ ] spec
  • [ ] pull

damondouglas avatar Jan 26 '15 22:01 damondouglas

Removed completion since all the code for that is in the unscripted package. And unscripted already has tests for it.

seaneagan avatar Jan 27 '15 20:01 seaneagan

@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 avatar Jan 29 '15 17:01 damondouglas

@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.

seaneagan avatar Jan 30 '15 22:01 seaneagan

So for example you would want to unit test InstallCommand.

seaneagan avatar Jan 30 '15 22:01 seaneagan

@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.

damondouglas avatar Feb 06 '15 16:02 damondouglas

@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.

damondouglas avatar Feb 08 '15 17:02 damondouglas

@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

damondouglas avatar Mar 21 '15 16:03 damondouglas