-
Notifications
You must be signed in to change notification settings - Fork 171
cue test
support
#209
Comments
PLEASE NOTE: I am in the middle of reworking ipcf/t to align nicer with the way cuelang tests naturally get written. The current setup is a little cumbersome. I briefly introduced list support for defining asserts but reverted it as I found that use of disjunctions made I am also in the process of moving away from the rspec describe syntax. I've found it to be combersome and out of place in the context of cuelang. I'm working toward an an api similar to node-tap specifically the |
Here is my take.
Some of this should be provided natively by the cue tool, other parts can be provided by a library. In CUE we can step it up a notch using CUE
Anyway, let's start simple by specifying a data representation that is future proof. I was thinking more along the line of allowing hierarchical tests where you assign a value to a $test field to trigger a certain test, such as:
and have the testing framework automatically expand this by filling out the test results and running trim as follows:
or something like that. Note that this is a fairly primitive (Go style) and would allow other frameworks to be mapped on top. Not user whether you would need to import a testing package or not. A fuzzer could even automatically populate the test cases, either statically or dynamically. For instance (rough sketch):
or something like
could tell the test tool to automatically create instances of the enclosing template. This may be useful for testing roundtrips between converters for different APIs. Testing those then becomes a matter of I used the Fuzzing may generate large tests sets and it may make sense to either not write them out (but reproduce them on the fly), or put them in a separate file or Many open questions remain. One I don't have a clear picture of is how to represent tool tests, for instance. |
I think a good first question is, what kind of things do people want to test? |
It would be good to get others feedback than mine since my use-case for cue is somewhat unique but the kinds of things I've been testing are mostly just sanity checks. Does a regex do what I expect it to, is a closed struct actually a closed struct, is a number actually a number etc. The nature of cue likely doesn't warrant exotic test suites but good to have a mechanism to do some basic checks. |
@mpvl Here is my latest update to It makes for a pretty clean workflow and is similar to the feel of golang testing:
I didn't use the Although, I could see using |
I like the idea of having a "simple" testing setup as @mpvl mentioned. My test use cases are similar to those of @rudolph9. But I think a more powerful approach to solve this problem is to implement a framework similar to haskells quickcheck (not sure if this falls into the fuzzer category) instead of describing valid and invalid cases. |
This issue has been migrated to cue-lang/cue#209. For more details about CUE's migration to a new home, please see cue-lang/cue#1078. |
Cuelang has reserved
*_test.cue
similar to golang but does not yet have support for actually running tests.Unless there is a good reason to follow a different path it seems reasonable to model cuelang testing after golang testing
Ideally we would "eat our own dog food" for testing and not create new builtin function but rather express the logic of the test using cuelang.
An example of a testing package is https://github.com/ipcf/t.
The text was updated successfully, but these errors were encountered: