-
Notifications
You must be signed in to change notification settings - Fork 326
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
Could the frame support data provider function? #135
Comments
@IVANOPT Could you explain a bit more what you mean and how you would use it? Thanks! |
I mean, always we run api tests use multiple variable group, most of them are same, for example:
how do we provider different data each time only instead of write the whole test module. In java, we use @dataProvider annotation, you may find more introductions from the link: http://www.mkyong.com/unittest/testng-parameter-testing-example/ In addition, how to check result size greater than 0, which type is list. If there are some operations to validate the list type accurate and how ? Thanks. |
@IVANOPT PyRestTest supports several ways to achieve what you need here, in order from simplest to most complex:
The advanced guide provides information on how to use these. Checking for a list with result size >1 (validators element): - validators:
- compare: {jsonpath_mini: 'my.value', comparator: 'type', expected: 'list' }
- extract_test: {jsonpath_mini: 'my.value.0', test: 'exists' } The extract_test there is asserting that the 1st element in the list exists, so it'll check for >= 1 element. I haven't run the above, so there may be minor typos, but it will do what you want. |
Thanks, helps me a lot. I have some other questions in usage.
if I just want to execute one of the tests of example.yaml, for example, example.yaml includes testA and testB, how to run testA only?
Then I called api to test the result, I got error messages below:
Obvious that by calling the api call, I got the result with 'u' character...how to compare the above two lists? If the process right? Thanks for help more. |
Not currently supported, the solution is to break them into separate files and use 'import' statements in a parent testset if you want to sometimes run them as a unit. It will become a feature if I can make a convenient unittest wrapper for these though (tied to the large xUnit compatible output feature in issues).
Not quite: you're comparing a python object (extracted from JSON) to a raw string (templates all evaluate to strings). What you probably want to do do is: - compare: {jsonpath_mini: 'data.city.0', expected: 'Atlanta'} OR if you want to use the variables, you can use a regex (hacky but it works): - compare: {jsonpath_mini: 'data.city.0', comparator:'regex', expected: {template: '.*$default_city.*'} } |
Solved the problems, really hacky, I'll think more about the solutions to make it more convenient, thanks. |
@IVANOPT Glad it was helpful. I've got plans to improve this, but it'll take some time to implement (and to do it in a way that doesn't break things for existing users). Since it sounds like your questions have been been answered (and existing enhancement proposals cover your needs), I'm going to go ahead and close out the issue for now. But I would be happy to assist in other issues if you have further questions (or reopen the one if there are further questions on the same subject). Cheers! |
Could the frame support data provider, in java, we use data provider annotation to prepare test data.
The text was updated successfully, but these errors were encountered: