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

Discussion on testing coverage for glom #65

Open
tonybaloney opened this issue Dec 5, 2018 · 1 comment
Open

Discussion on testing coverage for glom #65

tonybaloney opened this issue Dec 5, 2018 · 1 comment

Comments

@tonybaloney
Copy link

I was thinking about the challenge of calculating the "coverage" of Glom that @mahmoud raised on the Test & Code podcast.

Manually writing parameterised tests for Pytest would be cumbersome and also you wouldn't know the coverage

In the JSON specification, there are objects and arrays, an object can contain values with a fixed list of types, and an array can contain either arrays or objects.


and then an array

As there is only a fixed number of types for a value,

If you converted this into a feature matrix, you could then (deciding on N) first, map out the potential combinations.

Feature 1 Feature 2 Feature 3 Feature 4 Feature-N
null object object object object
string number array array
string

Then converting that feature matrix into a numpy array, you could dynamically generate all of the possible combinations. Since JSON supports an infinite level of nesting, you would have to fix the limted depth to N.

Once you have this you can calculate the possible number of combinations, create test data for each and use them as parameterised values.

Then, since Glom is a DSL, you again decide on N levels of operations-deep and calculate the same feature matrix for Glom.

The possible number of combinations (and your 100% coverage) is then a product of the 2 feature matrices.

You could apply the same technique to generate the same tests.

@kurtbrose
Copy link
Collaborator

#66 maybe apt :-)

@mahmoud mahmoud mentioned this issue Oct 29, 2019
3 tasks
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

2 participants