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

Upgrade YAML test #239

Closed
11 tasks
Vinatorul opened this issue Sep 8, 2015 · 7 comments
Closed
11 tasks

Upgrade YAML test #239

Vinatorul opened this issue Sep 8, 2015 · 7 comments

Comments

@Vinatorul
Copy link
Contributor

Now yaml test only check yml parsing, but not the the work in general.
I think we need to add:

  • flags tests
  • options test
  • positionals test
  • requirement test
  • conflicts test
  • override tess
  • multiple args
  • takes value args
  • min and max values
  • arg group test
  • subcommand test
@kbknapp
Copy link
Member

kbknapp commented Sep 8, 2015

Unless I'm not understanding the question/issue, so long as the Yaml parser spits out a valid App it's good. Checking that App is doing what it's supposed to isn't the job of the Yaml tests. Similar to the soon-to-be-new macros. We just need to verify that the Yaml parser is spitting out the intended App struct with all the specific settings we wrote in the .yml

...or maybe I'm misunderstanding 😜

@Vinatorul
Copy link
Contributor Author

As I tried to explain the idea of test it macros PR - we can't claim that it work as it assumed.
We can say - yes, it is doing something, but can't say what it is doing.
I can agree that integration test is overkill, but we have no unit test for yaml functions. So we cant proove them working well.

@sru
Copy link
Contributor

sru commented Sep 9, 2015

We are only testing the validity, not the correctness. Currently, we have no way to tell from tests that parsing YAML will work as intended and not explode on your face.

I agree with @kbknapp that the YAML tests shouldn't check what App is doing, but I believe that we should check if YAML parsing results in intended App.

For example:

// Note: this is an over-simplified unit test example.
use super::{YamlLoader, App};

#[test]
fn parse_yaml_author() {
    let yml = "
name: claptests
author: Kevin K. <kbknapp@gmail.com>";

    let app = App::from_yaml(YamlLoader::load_from_str(yml).unwrap());

    assert_eq!(Some("Kevin K. <kbknapp@gmail.com>"), app.author);
}

@WildCryptoFox
Copy link

Both macro and yaml parsers need to have their testing done by checking that they have performed the expected builder functions against the App. @sru 's assert_eq method should work well.

For the macro case, I manually verified the generated code - it could still do with a test case; as @Vinatorul pointed out for at least regression testing.

@Vinatorul
Copy link
Contributor Author

@sru I told about something like this, but I also think that integration test is overkill.
We need to test functions like this:
https://github.com/kbknapp/clap-rs/blob/master/src/args/group.rs#L89
or this
https://github.com/kbknapp/clap-rs/blob/master/src/args/arg.rs#L164

Both false-negative and true-positive cases.

@Vinatorul
Copy link
Contributor Author

As we can see from #266 #267 #270 #271 these tests are "must have"

@kbknapp
Copy link
Member

kbknapp commented Sep 22, 2015

#270 is by design, so that's not really a bug. But yes, we should update the tests to ensure everything is good to go. ;)

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

No branches or pull requests

4 participants